This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:arduino:examples [2017/08/09 07:20] – kaupo.raid | en:arduino:examples [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 162: | Line 162: | ||
| { | { | ||
| // Get digital value of potentiometer | // Get digital value of potentiometer | ||
| - | | + | |
| | | ||
| // When potentiometer digital value is logical " | // When potentiometer digital value is logical " | ||
| Line 199: | Line 199: | ||
| { | { | ||
| // Get analog value of potentiometer | // Get analog value of potentiometer | ||
| - | | + | |
| | | ||
| // Turn LED on | // Turn LED on | ||
| Line 211: | Line 211: | ||
| | | ||
| // Halt the program for potentiometer analog value number of milliseconds | // Halt the program for potentiometer analog value number of milliseconds | ||
| - | delay(poteOlek); | + | delay(potState); |
| } | } | ||
| </ | </ | ||
| Line 238: | Line 238: | ||
| | | ||
| // When potentiometer value is greater than 0 then set LED on halt program for short period | // When potentiometer value is greater than 0 then set LED on halt program for short period | ||
| - | if (poteOlek | + | if (potState |
| { | { | ||
| digitalWrite(led, | digitalWrite(led, | ||
| - | delayMicroseconds(poteOlek); | + | delayMicroseconds(potState); |
| } | } | ||
| | | ||
| Line 248: | Line 248: | ||
| | | ||
| // Halt program for short period | // Halt program for short period | ||
| - | delayMicroseconds(1023 - poteOlek); | + | delayMicroseconds(1023 - potState); |
| } | } | ||
| </ | </ | ||
| Line 457: | Line 457: | ||
| // Print out explaining text | // Print out explaining text | ||
| - | lcd.print(" | + | lcd.print(" |
| lcd.setCursor(0, | lcd.setCursor(0, | ||
| - | lcd.print(" | + | lcd.print(" |
| } | } | ||
| void loop() | void loop() | ||
| Line 482: | Line 482: | ||
| // when infrared sensor does not see anything print out " | // when infrared sensor does not see anything print out " | ||
| - | if(infrapunaNaebObjekti | + | if(proximity |
| else lcd.print(" | else lcd.print(" | ||
| Line 515: | Line 515: | ||
| { | { | ||
| // Set driver control pins as output | // Set driver control pins as output | ||
| - | pinMode(vasak_A,OUTPUT); | + | pinMode(left_A,OUTPUT); |
| - | pinMode(vasak_B,OUTPUT); | + | pinMode(left_B,OUTPUT); |
| - | pinMode(parem_A,OUTPUT); | + | pinMode(right_A,OUTPUT); |
| - | pinMode(parem_B,OUTPUT); | + | pinMode(right_B,OUTPUT); |
| - | | + | |
| delay(2000); | delay(2000); | ||
| } | } | ||
| Line 527: | Line 527: | ||
| { | { | ||
| | | ||
| - | | + | |
| delay(2000); | delay(2000); | ||
| | | ||
| - | | + | |
| delay(500); | delay(500); | ||
| } | } | ||
| // This function controls the driver input pins to get correct motion | // This function controls the driver input pins to get correct motion | ||
| - | void mootorid(int left, int right) | + | void motors(int left, int right) |
| { | { | ||
| // Left Motor | // Left Motor | ||
| Line 550: | Line 550: | ||
| else | else | ||
| { // Left motor STOP | { // Left motor STOP | ||
| - | digitalWrite(vasak_A,LOW); | + | digitalWrite(left_A,LOW); |
| - | digitalWrite(vasak_B,LOW); | + | digitalWrite(left_B,LOW); |
| } | } | ||
| Line 593: | Line 593: | ||
| pinMode(right_B, | pinMode(right_B, | ||
| - | | + | |
| delay(2000); | delay(2000); | ||
| } | } | ||
| void loop() | void loop() | ||
| { | { | ||
| - | | + | |
| delay(2000); | delay(2000); | ||
| - | | + | |
| delay(2000); | delay(2000); | ||
| - | | + | |
| delay(2000); | delay(2000); | ||
| - | | + | |
| delay(2000); | delay(2000); | ||
| - | | + | |
| delay(2000); | delay(2000); | ||
| } | } | ||
| Line 616: | Line 616: | ||
| if(left > 0 && left <= 255) | if(left > 0 && left <= 255) | ||
| { // Left motor CW | { // Left motor CW | ||
| - | analogWrite(left_A, | + | analogWrite(left_A, |
| digitalWrite(left_B, | digitalWrite(left_B, | ||
| } | } | ||