Go Down

Topic: error, and check my code? avrdude: stk500_getsync(): not in sync: resp=0x30 (Read 1 time) previous topic - next topic

thebfs

i get this error when uploading code nano 328
Code: [Select]
avrdude: stk500_getsync(): not in sync: resp=0x30
also here is the code is their any problems with it?
Code: [Select]
// Constants:
// Outputs:
const int whitePin = 13;
const int bluePin = 12;
const int redPin = 11;

// Inputs:
const int blueButton = 6;
const int redButton = 5;

// Variables:
// Read: (has something physicaly attached)
int blueState = LOW;
int redState = LOW;
// Made: (has nothing physicaly attached)
int blueCount = 0;
int redCount = 0;
int blueCountTotal = 0;
int redCountTotal = 0;

void setup() {
  Serial.begin(9600);
  // initialize the pins outputs:
  pinMode(whitePin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  pinMode(redPin, OUTPUT);
  // initialize the pins inputs:
  pinMode(blueButton, INPUT);
  pinMode(redButton, INPUT);
 
}

void loop(){
  blueState = (digitalRead, blueButton);
  redState = (digitalRead, redButton);
 
  Serial.println("Blue State: ");
  Serial.println(blueState);
  delay(700);
  Serial.println("Red State: ");
  Serial.println(redState);
  delay(700);
 
  //00000000000000000000000
  while(blueState == 1){
    blueState = (digitalRead, blueButton);
    blueCount++;
    redCount--;
    blueCountTotal++;
    if(blueCount >= 30){
      blueCount = 30;
    }
    if(blueCount <= 0){
      blueCount = 0;
    }
    if(redCount >= 30){
      redCount = 30;
    }
    if(redCount <= 0){
      redCount = 0;
    }
    analogWrite(bluePin, 1000);
    analogWrite(redPin, 1000);
    delay(1000);
    // serial debug
    Serial.println("Blue Count Total: ");
    Serial.println(blueCountTotal);
    delay(700);
    Serial.println("Red Count Total: ");
    Serial.println(redCountTotal);
    delay(700);
    Serial.println("Blue Count: ");
    Serial.println(blueCount);
    delay(700);
    Serial.println("Red Count: ");
    Serial.println(redCount);
    delay(700);
    Serial.println("Blue State: ");
    Serial.println(blueState);
    delay(700);
    Serial.println("Red State: ");
    Serial.println(redState);
    delay(700);
   
  }
  //000000000000000000000000
 
  while(redState == HIGH){
   redState = (digitalRead, redButton);
   redCount++;
   blueCount--;
   redCountTotal++;
   if(redCount >= 30){
     redCount = 30;
   }
   if(redCount <= 0){
     redCount = 0;
   }
   if(blueCount >= 30){
     blueCount = 30;
   }
   if(blueCount <= 0){
     blueCount = 0;
   }
   analogWrite(redPin, 1000);
   analogWrite(bluePin, 1000);
   delay(1000);
  }
 
 
 
 
}

i want to controll the brightnees of the leds by how long a button is pressed.
one fades, adn the other lights

also can you have negative numbers so i could change my code to the buttons adding or subtracting, and if it is negative one lights with a certain brightness(depending on how negative)
and vice versa for positive?

woody_unreal

this maybe off track for your error .. but usally see the "sync" errors for om put not being set ,,, or just a simple unplug the Ardunio, close software, and start back up. Have you tryed those steps yeat :) ?
Often wrong port seleted :)

woody_unreal

I uploaded you Sketch without error,, but i didnt breadboard the rest..... so not sure of the other problems

raymadigan

When do you get the error?

When you are downloading?  Or running your sketch?

thebfs

thanks i found out i selected wrong board, mega i needed nano. it works.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy