Loading...
Pages: 1 [2]   Go Down
Author Topic: Simple button counter that increments by 5  (Read 251 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Delta_G
The code works as i want it to, but the code is probably full of wrong code and i will clean it up when the project is complete:)
Logged

Queens, New York
Online Online
Edison Member
*
Karma: 29
Posts: 1589
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'll explain what you have.

This will show 5 when the button is pressed. NOTE it will not start at 0, even when declaired "int Counter = 0;" the reason your Serial.println().
Code:
if (CurrentSwitch == LOW)
      {
        Counter=Counter+5;
        Serial.println(Counter); // <= This is the reason you see 5 instead of 0 because it is inside the same IF statement, however if you move
                                       // Serial.println(Counter); outside the IF statement it will start at 0, but it will show continious numbers.
      }
Logged

UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino

Arduino Tutorials, coming soon.

"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown

Pages: 1 [2]   Go Up
Print
 
Jump to: