I haven't got my Arduino Uno yet, but i already started writing some lines of my first code.
So I wanted to show you guys this and whould like to know what you think of it.
And maybe get the answer to one tiny question.
Q. Why do I get the following error message.
(Sketch1.ino: In function 'void loop()':
Sketch1:36: error: 'value' was not declared in this scope
Sketch1:42: error: 'value' was not declared in this scope
Sketch1:48: error: 'value' was not declared in this scope)
int analog0 = 0; // select the input pin for the potentiometer (FWD)
int analog1 = 1; // select the input pin for the potentiometer (Bck)
int analog2 = 2; // select the input pin for the potentiometer (Brake)
int buttonPin1 = 3; // select the input pin for the switch (FreeW)
int analogVal0 = 0; // variable to store the value coming from the sensor
int analogVal1 = 0; // variable to store the value coming from the sensor
int analogVal2 = 0; // variable to store the value coming from the sensor
const int buttonPin2 = 4; // the number of 1st pushbutton pin
int ledPin1 = 12; // the number of the LED pin (Left)
const int buttonPin3 = 5; // the number of 2st pushbutton pin
int ledPin2 = 13; // the number of the LED pin (Right)
int buttonState1 = 0; // variable for reading the pushbutton 1 status
int buttonState2 = 0; // variable for reading the pushbutton 2 status
int buttonState3 = 0; // variable for reading the pushbutton 2 status
void setup()
{
pinMode(6, OUTPUT);
pinMode(9, OUTPUT);
pinMode(2, OUTPUT);
pinMode(4, OUTPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
void loop()
{
{
analogVal0 = analogRead(analog0);
value /= 4;
digitalWrite (4, HIGH);
digitalWrite (6, value);
}
{
analogVal1 = analogRead(analog1);
value /= 4;
digitalWrite (2, HIGH);
digitalWrite (9, value);
}
{
analogVal1 = analogRead(analog2);
value /= 4;
digitalWrite (9, value);
digitalWrite (6, value);
}
{
analogVal1 = analogRead(buttonPin1);
digitalWrite (2, HIGH);
digitalWrite (4, HIGH);
}
buttonState2 = digitalRead(buttonPin2);
if (buttonState2 == HIGH)
{
digitalWrite(ledPin1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a half second
digitalWrite(ledPin1, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a half second
}
else
{
digitalWrite(ledPin1, LOW); // turn LED off
}
buttonState3 = digitalRead(buttonPin3);
if (buttonState2 == HIGH)
{
digitalWrite(ledPin2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a half second
digitalWrite(ledPin2, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a half second
}
else
{
digitalWrite(ledPin2, LOW); // turn LED off
}
}