This is an example of a past quiz that you can use for studying.
The following code example has problems 🙁 Circle the specific areas of the code that are obviously not right. If a given line of code one word that isnt right, circle that word, not just the whole line. Then explain what the problem is in the space provided or just write the correct code that would make it work properly. The comments are correct, otherwise every line has one thing wrong with it.
——————————————————-
/*
Analog Input
Demonstrates analog input by reading an analog sensor on analog pin 0 and
turning on and off a light emitting diode(LED) connected to digital pin 13.
The amount of time the LED will be on and off depends on
the value obtained by analogRead().
The circuit:
* Potentiometer attached to analog input 0
* center pin of the potentiometer to the analog pin
* one side pin (either one) to ground
* the other side pin to +5V
* LED anode (long leg) attached to digital output 13
* LED cathode (short leg) attached to ground
*/
int sensorPin = 5000; // select the input pin for the potentiometer
float ledPin = 13; // select the pin for the LED
const int sensorValue = 0; // variable to store the value coming from the sensor
void loop() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, INPUT);
{
void setup(){
// read the value from the sensor:
sensorValue = analogRead(ledPin);
// turn the ledPin on
digitalWrite(ledPin, LOW);
// stop the program for <sensorValue> milliseconds:
delay(1000);
// turn the ledPin off:
digitalWrite(ledPin, HIGH);
// stop the program for for <sensorValue> milliseconds:
delay(ledPin);
)
I know it late but can you post the correct version of the code?
Here you go man. It’s the ‘Analog Input’ example:
http://arduino.cc/en/Tutorial/AnalogInput