SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By JoeSasala
#189390
i am making a guessing game as a school project. there will be 4 sensors and 4 buttons that correspond to the sensor. players will take turns guessing at where the object is hidden. this is my first time writing code. it verifies but won't sync to the board so i don't know what to do. thanks for any help!

i am running on iOS 10.10.3 using Arduino 1.6.8 and using a spark fun red board from the inventors kit.

Here is the error code i keep getting. avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
Code: Select all
#define guesserWinPin 0 //green for guesser, red for shooter
#define guesserLosePin 1 //red for guesser, green for shooter
#define guessButt1 2 //sets up pins for buttons
#define guessButt2 3
#define guessButt3 4
#define guessButt4 5
#define sensorThreshold 200 //if sensors are uncovered
#define shooterSensor1 0
#define shooterSensor2 1 
#define shooterSensor3 2
#define shooterSensor4 3

void setup() {
 pinMode (guessButt1, INPUT_PULLUP);
 pinMode (guessButt2, INPUT_PULLUP);
 pinMode (guessButt3, INPUT_PULLUP);
 pinMode (guessButt4, INPUT_PULLUP);
 pinMode (guesserWinPin, OUTPUT);
 pinMode (guesserLosePin, OUTPUT);
}

void loop() {
  if (digitalRead(guessButt1) == 1)
  {
    if (analogRead(shooterSensor1) < sensorThreshold) //if it's lower, there's a shotglass on it
    {
    digitalWrite(guesserWinPin, HIGH); 
    delay (5000);
    digitalWrite(guesserWinPin, LOW);
    }
    else
    {
    digitalWrite(guesserLosePin, HIGH); 
    delay (5000);
    digitalWrite(guesserLosePin, LOW);
    }
  }
  if (digitalRead(guessButt2) == 1)
  {
    if (analogRead(shooterSensor2) < sensorThreshold) //if it's lower, there's a shotglass on it
    {
    digitalWrite(guesserWinPin, HIGH); 
    delay (5000);
    digitalWrite(guesserWinPin, LOW);
    }
    else
    {
    digitalWrite(guesserLosePin, HIGH); 
    delay (5000);
    digitalWrite(guesserLosePin, LOW);
    }
  }

  if (digitalRead(guessButt3) == 1)
  {
    if (analogRead(shooterSensor3) < sensorThreshold) //if it's lower, there's a shotglass on it
    {
    digitalWrite(guesserWinPin, HIGH); 
    delay (5000);
    digitalWrite(guesserWinPin, LOW);
    }
    else
    {
    digitalWrite(guesserLosePin, HIGH); 
    delay (5000);
    digitalWrite(guesserLosePin, LOW);
    }
  }


  if (digitalRead(guessButt4) == 1)
  {
    if (analogRead(shooterSensor4) < sensorThreshold) //if it's lower, there's a shotglass on it
    {
    digitalWrite(guesserWinPin, HIGH); 
    delay (5000);
    digitalWrite(guesserWinPin, LOW);
    }
    else
    {
    digitalWrite(guesserLosePin, HIGH); 
    delay (5000);
    digitalWrite(guesserLosePin, LOW);
    }
  } 
}
Last edited by JoeSasala on Tue Apr 19, 2016 11:11 am, edited 4 times in total.
By fll-freak
#189413
Well, first I will assume this is for an Arduino of some sort.
A Sync problem normally means you do not have the Arduino IDE setup properly. Perhaps the wrong COM port or the wrong board type. It could also be a wiring problem if you are not using a board with a build in USB like the minis or micros.

Your first step is to compile the sample blinking LED code and get that to work. Then you can look at your code.
By sterretje
#189418
As said, if it verifies it's not a code problem. Which OS are you using, which Arduino IDE version, which Arduino?

Next time, please post code between code tags; [ code ]your code here[ /code ] (without the spaces between the square brackets) will result in
Code: Select all
your code here