The first experience with Arduino

  • Dec 24, 2019
click fraud protection

I have long wanted to learn Arduino. It's very cheap microcomputer, which has 14 digital inputs / outputs and 6 analog inputs. For Arduino has many additional modules (sensors, keypads, screens, motors), for it created the program in simple language programming and loading via USB.

During large Chinese freebies before last fall I bought for 5 cents a bunch of cards and add-on modules. In the morning, I finally began to understand it all.


Arduino UNO is useful as a development platform (the board is directly connected to a computer, and all connections are made without soldering wires with connectors). Such payment on Aliexpress costs from $ 2.99. When the development is completed, in the finished device can use a much smaller size and a cheaper cost More Arduino Pro MiniHaving the same opportunities. She It costs less than $ 100 - $ 1.3.


Arduino is not a toy for me. I want to help her make a very specific, I needed the device. The first two things I want to do - and the electronic LATR goniophotometer.

instagram viewer

Goniophotometer - a device that allows to determine the luminous flux and illumination angle. It scrolls the motor cartridge with a bulb 360 degrees in the horizontal plane, measuring light level in each position of the lamp, and then calculates the light flux and angle.

Electronic LATR - a device that allows you to receive an alternating voltage of 1 to 256 volts in increments of 1 volt. It will come in handy for my test tubes and to adjust the fan speed (with conventional dimmers fans buzzing). The idea is to order small transformer with eight secondary windings 1, 2, 4, 8, 16, 32, 64 and 128 volts. Commuting them via relays controlled by the Arduino, you can get any voltage.

Today, I learned to control the stepper motor. Motor 28BYJ-48 together with the control board It costs only $ 1.65. It has a built-in gearbox and it makes a complete revolution in 2048 or 4096 of half-steps.

At first I tried to deal with the ready-made library and Stepper AccelStepper, but then I realized that it is easier to do without them and drive the motor directly.

I found on the internet and control wiring diagram software. Launched - spinning. I learned to make cycles. Then he figured out how to create functions. As a result, three hours after the first time in his life included the Arduino, I have created a function that knows how to make the right amount of motor steps.
The entire program, the motor is rotating clockwise by half a turn with a pause of 200 ms is as follows:

int pins [] = {8, 9, 10, 11}; // Set the pins in order

int phases = 8;

bool motorPhases [8] [4] = {// [phase] [pin]
// pins
// Winding A B A B
// Motor Pin 1 2 3 4
// Color Bl Pi Ye Or
{ 1, 1, 0, 0},
{ 0, 1, 0, 0},
{ 0, 1, 1, 0},
{ 0, 0, 1, 0},
{ 0, 0, 1, 1},
{ 0, 0, 0, 1},
{ 1, 0, 0, 1},
{ 1, 0, 0, 0}
};

void setup () {
for (int i = 0; i <4; i ++) pinMode (pins [i], OUTPUT);
}

int phase = 0;
int _step = 1; // If the step to change the sign on -1 - change the direction of rotation.

void loop () {
int a = 2047;
step (a);
delay (200);
}

void step (int x) {
int i;
for (i = 0; i{

phase + = _step;
if (phase> 7) phase = 0;
if (phase <0) phase = 7;

for (int i = 0; i <4; i ++) {
digitalWrite (pins [i], ((motorPhases [phase] [i] == 1)? HIGH: LOW));
}

// Pause for a spin on one half-step
delay (2);
}

digitalWrite (pins [0], LOW);
digitalWrite (pins [1], LOW);
digitalWrite (pins [2], LOW);
digitalWrite (pins [3], LOW);
}

Of course, still she has to deal with so many, but a successful start. :)

Today I ordered more module two-line LCD screen with six buttons for $ 2.60, A pair of modules with four power relays for $ 1.95 (There are eight modules and relays, but I decided that the two modules 4 relay convenient) chetyrohknopochnuyu membrane keypad for $ 0.53, Chetyrohrazryadny indicator for $ 1.4. More ordered two different sensor lighting for $ 0.4 and for $ 0.6But I missed them - they are the threshold and used to turn on lights at night. But nothing useful. Ordered tricky sensor with two photodiodes and two ADC for $ 1.75 and a simple sensor with analog output for $ 0.9.

© 2017 Alex Nadozhin

The main theme of my blog - Equipment for human life. I write reviews, share experiences, talk about all sorts of interesting things. And I'm doing stories of the interesting places and tell about interesting events.
Add me to your friend list
here. Remember the short address of my blog: Blog1.rf and Blog1rf.ru.

My second project - lamptest.ru. I test LED lamps and help figure out which ones are good and which are not.