Hi all,im trying to get this on to an arduino uno,it comes up with an error msg saying"expected unqualified-id before '(' token heres the sketch:
/*
http://www.bristolwatch.com/radio/arduino_coil_winder.htmArduino Stepper Motor Coil Winder
Lewis Loflin
lewis@bvu.net
*/
#define yellow 9 //Q1
#define orange 10 //Q2
#define brown 11 // Q3
#define black 12 // Q4
#define SW0 2
#define SW1 3
#define SW2 4
#define SW3 5
#include <OneWire.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
// set the LCD address to 0x27
int i, j;
void setup() {
pinMode(SW0, INPUT);
pinMode(SW1, INPUT);
pinMode(SW2, INPUT);
pinMode(SW3, INPUT);
digitalWrite(SW0, 1); // pull up on
digitalWrite(SW1, 1); // pull up on
digitalWrite(SW2, 1);
digitalWrite(SW3, 1);
lcd.init(); // initialize the lcd
lcd.backlight();
pinMode(black, OUTPUT);
pinMode(brown, OUTPUT);
pinMode(orange, OUTPUT);
pinMode(yellow, OUTPUT);
all_coils_off();
lcd.clear();
lcd.home();
lcd.print("Wait 2 sec.");
delay(2000); // wait for 2 seconds
lcd.setCursor(0, 1); // is Home
lcd.print("Ready to go!");
j = 0;
}
void loop() {
// set turns
if (!digitalRead(SW0) == 1) {
delay(1000);
j = 0;
lcd.clear();
lcd.home();
lcd.print("Turns = 0 ");
while (!digitalRead(SW0) == 1) {
delay(1000);
if (!digitalRead(SW1) == 1) j = j + 1;
if (!digitalRead(SW2) == 1) j = j + 10;
lcd.setCursor(8, 0);
lcd.print(j);
} // end while
lcd.setCursor(0, 1);
lcd.print("Ready to wind.");
}
if (!digitalRead(SW3)) {
lcd.clear();
lcd.home();
lcd.print("Turns 0 ");
for (i = 1; i <= j; i++) {
reverse(200);
lcd.setCursor(6, 0);
lcd.print(i);
}
all_coils_off();
lcd.setCursor(0, 1);
lcd.print("Finished ");
}
} // end loop
void all_coils_off(void) {
digitalWrite(black, 0);
digitalWrite(brown, 0);
digitalWrite(orange, 0);
digitalWrite(yellow, 0);
}
void reverse(int i) {
while (1) {
digitalWrite(black, 1);
digitalWrite(brown, 0);
digitalWrite(orange, 0);
digitalWrite(yellow, 1);
delay(analogRead(0) / 4 + 5);
i--;
if (i < 1) break;
digitalWrite(black, 0);
digitalWrite(brown, 1);
digitalWrite(orange, 0);
digitalWrite(yellow, 1);
delay(analogRead(0) / 4 + 5);
i--;
if (i < 1) break;
digitalWrite(black, 0);
digitalWrite(brown, 1);
digitalWrite(orange, 1);
digitalWrite(yellow, 0);
delay(analogRead(0) / 4 + 5);
i--;
if (i < 1) break;
digitalWrite(black, 1);
digitalWrite(brown, 0);
digitalWrite(orange, 1);
digitalWrite(yellow, 0);
delay(analogRead(0) / 4 + 5);
i--;
if (i < 1) break;
}
}
any idear what im doing wrong?,cheers Paul.