can someone please tell me how i can make a program, on the Arduino, that counts every time i read a specific analog value? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

can someone please tell me how i can make a program, on the Arduino, that counts every time i read a specific analog value?

arduino counter

8th Apr 2018, 11:53 AM
Olav Sie
Olav Sie - avatar
2 Answers
+ 3
int count = 0; void loop() { if(analogRead(A0)) { count++; } }
8th Apr 2018, 1:02 PM
Toni Isotalo
Toni Isotalo - avatar
+ 1
if i understood your question properly, it should look like this: const int yourValue=345; int counter=0; void setup(){ Serial.begin(115200); } void loop(){ if (analogRead(A0)==yourValue){ counter++; Serial.println(counter); } }
17th Apr 2018, 8:55 AM
seamiki
seamiki - avatar