for some reason if my code starts out with "#define" I get the following error.
In file included from C:\Users\Mike\Desktop\arduino-0022\hardware\arduino\cores\arduino/WProgram.h:10,
from sketch_mar12a.cpp:7:
C:\Users\Mike\Desktop\arduino-0022\hardware\arduino\cores\arduino/wiring.h:122: error: expected ',' or '...' before numeric constant
C:\Users\Mike\Desktop\arduino-0022\hardware\arduino\cores\arduino/wiring.h:123: error: expected ',' or '...' before numeric constant
but if I just put an arbitrary piece of code, for example, byte a = 0; above the #define section the code compiles correctly.
This codes doesn't compile:
#define latchPin 7
#define dataPin 9
#define clockPin 8
//byte switchVar1 = 72; //01001000
void setup() {
Serial.begin(9600);
pinMode(latchPin, INPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
}
void loop() {
if (digitalRead(latchPin) == HIGH){
while(digitalRead(latchPin) == HIGH){
delay(1);
}
if (digitalRead(latchPin) == LOW){
byte myDataIn = 0;
for (int i=0; i<8; i++){
digitalWrite(clockPin, 0);
delayMicroseconds(0.2);
if (digitalRead(dataPin)) {
myDataIn = myDataIn | (1 << i);
}
digitalWrite(clockPin, 1);
}
Serial.println(myDataIn,BIN);
}
}
}
This works:
byte a=0;
#define latchPin 7
#define dataPin 9
#define clockPin 8
//byte switchVar1 = 72; //01001000
void setup() {
Serial.begin(9600);
pinMode(latchPin, INPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
}
void loop() {
if (digitalRead(latchPin) == HIGH){
while(digitalRead(latchPin) == HIGH){
delay(1);
}
if (digitalRead(latchPin) == LOW){
byte myDataIn = 0;
for (int i=0; i<8; i++){
digitalWrite(clockPin, 0);
delayMicroseconds(0.2);
if (digitalRead(dataPin)) {
myDataIn = myDataIn | (1 << i);
}
digitalWrite(clockPin, 1);
}
Serial.println(myDataIn,BIN);
}
}
}
Any ideas why this is so?