processing - My Arduino automatic LED 'nightlight' is not working -
processing - My Arduino automatic LED 'nightlight' is not working -
i have arduino uno, , i'm trying write programme if photoresistor detects low amount of light, led turns on. here code.
int led = 2; int phores = a4; int val = 0; void setup() { pinmode(led, output); pinmode(phores, input); serial.begin(9600); } void loop() { val = analogread(phores); if(val > 256) { digitalwrite(led, high); } if(val < 256) { digitalwrite(led, low); } serial.println(val); }
you might need set sec if block within loop function. i'm pretty should prepare things. adding little delay might thought avoid doing check @ every iteration.
arduino processing led arduino-ide arduino-uno
Comments
Post a Comment