Hello!
I have been messing with my arduino and programming for the past 3 weeks or so (not consistently).
I understand how to set up the arduino with the breadboard and components, but I have a hard time
coming up with some commands.
Current Project:
I have set up a photo resister to be activated when the light of a shining red laser beam is interrupted, like a trip wire/sensor. I then programmed my LCD to serve as a timer. Now I'm trying to set them up together.
I want to be able to start the timer once the photo resistor is: activated -> dis-activated -> activated (shining light on semsor, no laser shines over it, then the laser shines on it again) as if something blocked the sensor for a second then send the signal to start the timer.
I also need to make sure the timer doesnt start counting again if it gets tripped more than once in a single run.
I know how i must set up the arduino physically but I just cant figure out how to code it
the code should say something like this (not a real code):
if the digital input from the photo resistor is HIGH then LOW then HIGH again send a signal to the lcd to start the timer
and then make sure the timer wont restart if the light beam is disrupted again.
I wrote very simple codes for both the lcd timer and the photo resistor
LCD code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup() {
lcd.begin(16, 2);
lcd.print("timer:");
}
void loop()
{
lcd.setCursor(0, 6);
lcd.print(millis()/1000);
}
Photo Resistor Code:
/* Photo Resistor */
const int sensorPin = 0;
const int ledPin = 13;
int lightLevel, high = 0, low = 1023;
void setup()
{
pinMode(ledPin, OUTPUT);
}
void loop()
{
lightLevel = analogRead(sensorPin);
manualTune();
analogWrite(ledPin, lightLevel);
}
void manualTune()
{
lightLevel = map(lightLevel, 100, 200, 0, 255);
lightLevel = constrain(lightLevel, 0, 255);
}
Does anyone have any clever ideas on how to set the communication between photo resistor part and the LCD timer?