I have designed the electronics for the ignition system for my old 49 tractor, but have come up against a brick wall with the coding for the Arduino.
It simply didn't work, and after repeatedly simplifying the code to find the problem, I found that I can never get a valid input from the pin.
Here's the code I trimmed it down to:
void setup(){
Serial.begin(9600);
pinMode(7, INPUT);
}
void(loop){
int pinState = (digitalRead, 7);
Serial.print(pinState);
delay(1000);
}
When I run it I get a row of 7's on the serial monitor. Tied pin 7 to ground to cut out any stray signals and got a row of 7's, tied it to 5 volts and got the same row of 7's.
Changed the code so that pin 3 was the input and got a row of 3's !!!!!!
Replaced the Atmega 328 on the board but got the exact same results.
What am I doing wrong?
It simply didn't work, and after repeatedly simplifying the code to find the problem, I found that I can never get a valid input from the pin.
Here's the code I trimmed it down to:
void setup(){
Serial.begin(9600);
pinMode(7, INPUT);
}
void(loop){
int pinState = (digitalRead, 7);
Serial.print(pinState);
delay(1000);
}
When I run it I get a row of 7's on the serial monitor. Tied pin 7 to ground to cut out any stray signals and got a row of 7's, tied it to 5 volts and got the same row of 7's.
Changed the code so that pin 3 was the input and got a row of 3's !!!!!!
Replaced the Atmega 328 on the board but got the exact same results.
What am I doing wrong?