Kit Task 1 - Blinking LED


Code: 
 int ledPin = 12;

void setup() 
{
  pinMode(ledPin, OUTPUT);      // Set pin 12 to output
}

void loop() 
{
  digitalWrite(ledPin, HIGH);   // Turn on the LED
  delay(1000);              // Wait for 1 second
  digitalWrite(ledPin, LOW);    // Turn off the LED
  delay(500);              // Wait for 500ms
}

Changed LED pinout, so only the breadboard LED blinks.
Made a single integer variable for the LED pin to reduce repeating code.
Changed the delays so the LED stays on for twice as long as it is off. 


Kit Task 2 - Potentiometer



Code
int ledPin = 12;
int potPosition;       //this variable will hold a value based on the position of the potentiometer

void setup()
{
  Serial.begin(9600);       //start a serial connection with the computer
  pinMode(ledPin, OUTPUT);      //set pin 12 as an output that can be set to HIGH or LOW
}

void loop()
{
  //read the position of the pot
  potPosition = analogRead(A4);    //set potPosition to a number between 0 and 1023 based on how far the knob is turned
  Serial.println(potPosition);     //print the value of potPosition in the serial monitor on the computer

  //change the LED blink speed based on the pot value
  digitalWrite(ledPin, HIGH);           // Turn on the LED
  delay(potPosition);              // delay for as many miliseconds as potPosition (0-1023)

  digitalWrite(ledPin, LOW);            // Turn off the LED
  delay(potPosition);              // delay for as many miliseconds as potPosition (0-1023)
}

Changed LED pinout, so only the breadboard LED blinks.
Made a single integer variable for the LED pin to reduce repeating code. 
Changed the pinout of the potentiometer. 


Kit Task 3 - Photoresistor
Code:
pinMode(12, OUTPUT);              //set pin 12 as an output that can be set to HIGH or LOW
photoresistor = analogRead(A4);   //set photoresistor to a number between 0 and 1023 based on how far the knob is turned
  if (photoresistor < threshold){
    digitalWrite(12, HIGH);         // Turn on the LED 
  } else{
    digitalWrite(12, LOW);          // Turn off the LED
  }
  delay(50);                       //short delay to make the printout easier to read
}


Changed pin out for LED
Changed pin out for photoresistor
Changed delay to be 50ms from 100ms 
Photo taken with flash to show LED turned off 




Kit Task 4 - RGB Nightlight
Code:
int threshold = 200;            //if the photoresistor reading is lower than this value the light will turn on
photoresistor = analogRead(A5);         //read the value of the photoresistor

potentiometer = analogRead(A1);

Changed so the light only comes on if it's really super dark. 
Changed the pins used on the arduino. 


Kit Task 5 - Buzzer

Code: 
int speakerPin = 3;               //the pin that buzzer is connected to
int beatLength = 80;   //the length of one beat (changing this will speed up or slow down the tempo of the song)

Changed the beat length, makes the song much faster
Changed the speaker pinout.



Kit Task 6 - Digital Trumpet



Code:
  if(digitalRead(firstKeyPin) == LOW){        //if the first key is pressed
    tone(buzzerPin, 440);                     //play the frequency for c
  }
  else if(digitalRead(secondKeyPin) == LOW){  //if the second key is pressed
    tone(buzzerPin, 494);                     //play the frequency for e
  }
  else if(digitalRead(thirdKeyPin) == LOW){   //if the third key is pressed
    tone(buzzerPin, 523);                     //play the frequency for g
  }


Changed the frequency of the button tones

 

Kit Task 7 - Simon Says

Code:
int roundsToWin = 3;         //number of rounds the player has to play before they win the game (the array can only hold up to 16 rounds)

Changed the amount of rounds, makes the game easier



Kit Task 8 - Servo Motors


Code:
myservo.attach(7);        //tell the servo object that its servo is plugged into pin 9

Changed the pin the servo signal pin is attached to


Kit Task 9 - Distance Sensor

Code: 
delay(20);      //delay 20ms between each reading

Changed the delay between readings to make the transition between colours more responsive.

Comments

Popular posts from this blog

Sensor Project - Reverse Proximity Sensor

LED Project - Das Blinkenlights