State Change Detection, Arduino for Dummies, Page 221 (MVI 8050)

preview_player
Показать описание
Making a Better Button, Setting Up the State Change Detection Sketch, Arduino for Dummies, Page 221.

Every four button presses the LED is turned on.
This version does not include switch debounce.
Рекомендации по теме
Комментарии
Автор

I am looking for code to detect state change of a rotary encoder sensor to write an envent when the direction changes.

jameselliott
Автор

im a beginner in Arduino so why this code didn't work to do so or why i use serial is first place, (int led=13;
int p=5;
int count=0;
void setup()
{pinMode(led, OUTPUT);
pinMode(p, INPUT);}
void loop()
{ if(digitalRead(p)==HIGH)
{count++;} if(count%2 != 0){digitalWrite(led, LOW);}
else{digitalWrite(led, HIGH);}} )
Thanks

YouHaveToGo