Components and supplies
1
Arduino UNO
1
LED (generic)
1
Resistor 220 ohm
1
Single Turn Potentiometer- 10k ohms
Apps and platforms
1
Arduino IDE
Project description
Code
Strobe_lcd.ino
c_cpp
1#include <LiquidCrystal.h> 2// connections 3int ledPin = 13; 4const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 5 6unsigned long ontime = 200; // The time, the led is turned on in microseconds. The best is between 100 and 300 microseconds. 7unsigned long cycletime; 8 9int one; 10int ten; 11int onehundred; 12int rps; 13int prevrps; 14unsigned long delayms; 15 16void setup() { 17 pinMode(ledPin,OUTPUT); 18 pinMode(A5,INPUT); // change these to your potentiometer outputs 19 pinMode(A4,INPUT); 20 pinMode(A3,INPUT); 21 Serial.begin(9600); 22 LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 23 lcd.begin(16,2); 24 lcd.clear(); 25 26 cycletime = ontime + 1000000; 27 delayms = micros()+(cycletime/rps); 28} 29 30void loop() { 31 32 one = map(analogRead(A3),0,1023,0,9); // the math for the delay 33 ten = map(analogRead(A4),0,1023,0,9); 34 onehundred = map(analogRead(A5),0,1023,0,20); 35 ten = ten*10; 36 onehundred = onehundred*100; 37 rps = onehundred+ten+one; 38 rps = rps+1; 39 if(prevrps != rps){ 40 lcd.clear(); 41 lcd.setCursor(5,0); 42 lcd.print("speed:"); 43 lcd.setCursor(4,1); 44 lcd.print(rps); 45 Serial.println("rps"); 46 } 47 48 if(delayms < micros()){ // the pulse 49 digitalWrite(ledPin,HIGH); 50 delayMicroseconds(ontime); 51 digitalWrite(ledPin,LOW); 52 delayms = micros()+cycletime/rps; 53 } 54} 55
Strobe.ino
c_cpp
The code is pretty self explaining.
1// connections 2int ledPin = 13; 3 4unsigned long ontime = 200; // The time, the led is turned on in microseconds. The best is between 100 and 300 microseconds. 5unsigned long cycletime; 6 7int one; 8int ten; 9int onehundred; 10int rps; 11unsigned long delayms; 12 13void setup() { 14 pinMode(ledPin,OUTPUT); 15 pinMode(A5,INPUT); // change these to your potentiometer outputs 16 pinMode(A4,INPUT); 17 pinMode(A3,INPUT); 18 Serial.begin(9600); 19 cycletime = ontime + 1000000; 20 delayms = micros()+(cycletime/rps); 21} 22 23void loop() { 24 25 one = map(analogRead(A3),0,1023,0,9); // the math for the delay 26 ten = map(analogRead(A4),0,1023,0,9); 27 onehundred = map(analogRead(A5),0,1023,0,20); 28 ten = ten*10; 29 onehundred = onehundred*100; 30 rps = onehundred+ten+one; 31 rps = rps+1; 32 33 Serial.print(rps); 34 Serial.println("rps"); 35 36 if(delayms < micros()){ // the pulse 37 digitalWrite(ledPin,HIGH); 38 delayMicroseconds(ontime); 39 digitalWrite(ledPin,LOW); 40 delayms = micros()+cycletime/rps; 41 } 42} 43
Strobe_lcd.ino
c_cpp
1#include <LiquidCrystal.h> 2// connections 3int ledPin = 13; 4const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 5 6unsigned long ontime = 200; // The time, the led is turned on in microseconds. The best is between 100 and 300 microseconds. 7unsigned long cycletime; 8 9int one; 10int ten; 11int onehundred; 12int rps; 13int prevrps; 14unsigned long delayms; 15 16void setup() { 17 pinMode(ledPin,OUTPUT); 18 pinMode(A5,INPUT); // change these to your potentiometer outputs 19 pinMode(A4,INPUT); 20 pinMode(A3,INPUT); 21 Serial.begin(9600); 22 LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 23 lcd.begin(16,2); 24 lcd.clear(); 25 26 cycletime = ontime + 1000000; 27 delayms = micros()+(cycletime/rps); 28} 29 30void loop() { 31 32 one = map(analogRead(A3),0,1023,0,9); // the math for the delay 33 ten = map(analogRead(A4),0,1023,0,9); 34 onehundred = map(analogRead(A5),0,1023,0,20); 35 ten = ten*10; 36 onehundred = onehundred*100; 37 rps = onehundred+ten+one; 38 rps = rps+1; 39 if(prevrps != rps){ 40 lcd.clear(); 41 lcd.setCursor(5,0); 42 lcd.print("speed:"); 43 lcd.setCursor(4,1); 44 lcd.print(rps); 45 Serial.println("rps"); 46 } 47 48 if(delayms < micros()){ // the pulse 49 digitalWrite(ledPin,HIGH); 50 delayMicroseconds(ontime); 51 digitalWrite(ledPin,LOW); 52 delayms = micros()+cycletime/rps; 53 } 54} 55
Strobe.ino
c_cpp
The code is pretty self explaining.
1// connections 2int ledPin = 13; 3 4unsigned long ontime = 200; 5 // The time, the led is turned on in microseconds. The best is between 100 and 6 300 microseconds. 7unsigned long cycletime; 8 9int one; 10int ten; 11int 12 onehundred; 13int rps; 14unsigned long delayms; 15 16void setup() { 17 pinMode(ledPin,OUTPUT); 18 19 pinMode(A5,INPUT); // change these to your potentiometer outputs 20 21 pinMode(A4,INPUT); 22 pinMode(A3,INPUT); 23 Serial.begin(9600); 24 cycletime 25 = ontime + 1000000; 26 delayms = micros()+(cycletime/rps); 27} 28 29void loop() 30 { 31 32 one = map(analogRead(A3),0,1023,0,9); // the math for the delay 33 34 ten = map(analogRead(A4),0,1023,0,9); 35 onehundred = map(analogRead(A5),0,1023,0,20); 36 37 ten = ten*10; 38 onehundred = onehundred*100; 39 rps = onehundred+ten+one; 40 41 rps = rps+1; 42 43 Serial.print(rps); 44 Serial.println("rps"); 45 46 47 if(delayms < micros()){ // the pulse 48 digitalWrite(ledPin,HIGH); 49 50 delayMicroseconds(ontime); 51 digitalWrite(ledPin,LOW); 52 delayms = micros()+cycletime/rps; 53 54 } 55} 56
Downloadable files
The scematic as pdf
The scematic as pdf
The scematic as pdf
The scematic as pdf
The scematic
The scematic
Comments
Only logged in users can leave comments