Hi Everyone,
I am wondering if someone could please look over my source code and possibly help me out with fixing it. I am completely stumped on what to do. Thanks in advance!
const int ledPins[] = { // pins that LED's are attached too
13, 12, 11, 10 };
const int buttonPin1 = 3;
const int buttonPin2 = 4; // pins switches are attached too
const int buttonPin3 = 5;
const int mPin = 52; // pin motor is attached too
int pinCount = 8
// Variables will change:
int buttonPushCounter = 0 // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0;
void setup() {
// initialize the button pin as a input:
pinMode(buttonPin1 3, INPUT);
pinMode(buttonPin2 4, INPUT);
pinMode(buttonPin3 5, INPUT);
//initialize the LED as an output:
pinMode(ledPin 13, OUTPUT);
pinMode(ledPin 12, OUTPUT);
pinMode(ledPin 11, OUTPUT);
pinMode(ledPIn 10, OUTPUT);
pinMode(mPin 52, OUTPUT);
Serial.begin(9600);
}
void loop() {
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);
// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button
// wend from off to on:
buttonPushCounter++;
Serial.println("on");
Serial.print("number of button pushes: ");
Serial.println(buttonPushCounter, DEC);
}
else {
// if the current state is LOW then the button
// wend from on to off:
Serial.println("off");
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
// turns on the LED every button push by
// checking the modulo of the button push counter.
// the modulo function gives you the remainder of
// the division of two numbers:
if (buttonPushCounter % 2 == 1 ) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
switch (buttonPin3) {
case 'a': // High Speed
if (buttonPushCounter % 2 == 1) {
digitalWrite(ledPin 13, HIGH);
digitalWrite(ledPin 12, HIGH);
digitalWrite(ledPin 11, HIGH);
digitalWrite(mPin, HIGH);
} else {
digitalWrite(ledPin 13, LOW);
digitalWrite(ledPin 12, LOW);
digitalWrite(ledPin 11, LOW);
digitalWrite(mPin, LOW);
}
break;
default:
// turn all LEDs off:
for (int thisPin = 2; thisPin < 7; thisPin++) {
digitalWrite(thisPin, LOW);
}
}
switch (buttonPin4) {
case 'b': // medium speed
if (buttonPushCounter % 2 == 1); {
digitalWrite(ledPin 12, HIGH);
digitalWrite(ledPin 11, HIGH);
digitalWrite(mPin, HIGH);
}
else {
digitalWrite(ledPin 13, LOW);
digitalWrite(ledPin 12, LOW);
digitalWrite(ledPin 11, LOW);
digitalWrite(mPin, LOW);
}
switch (buttonPin5) {
case 'c': // low speed
if (buttonPushCounter % 2 == 1) {
digitalWrite(ledPin 11, HIGH);
digitalWrite(mPin, HIGH);
} else {
digitalWrite(ledPin 13, LOW);
digitalWrite(ledPin 12, LOW);
digitalWrite(ledPin 11, LOW);
digitalWrite(mPin, LOW);
}
}
case 'd': //battery indicator