i get this error when uploading code nano 328avrdude: stk500_getsync(): not in sync: resp=0x30
also here is the code is their any problems with it?
// 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?