Blink Bumblebee's Eyes On and Off
//Fade through the colors of Bumblebee’s eyes
#include "LEDStrip.h" //The LEDStrip.h library gives your code access to special functions exclusive to the LED Strip
LEDStrip strip = LEDStrip(1, 13, 12); //Set up the strip by defining how many pixels (50) and which pins of the microchip are used (always 13 and 12 on Code Lab)
void setup() {
for(int i =8;i<12;i++){
pinMode(i,OUTPUT);
}
pinMode(6,INPUT_PULLUP);
pinMode(7,INPUT_PULLUP);
pinMode(A0,INPUT);
}
void loop() {
for(int i = 1;i<300;i++){
strip.setPixel(0,i);
strip.draw();
delay(5);
}
}
//Raise and lower the tone on Bumblebee with button presses
void setup() {
for(int i =8;i<12;i++){
pinMode(i,OUTPUT);
}
pinMode(6,INPUT_PULLUP);
pinMode(7,INPUT_PULLUP);
pinMode(A0,INPUT);
}
int pitch = 100;
void loop() {
if(digitalRead(6)==LOW){
pitch--;
delay(10);
tone(A5,pitch);
}
else if(digitalRead(7)==LOW){
pitch++;
delay(10);
tone(A5,pitch);
}
else{
noTone(A5);
}
}
//Press Button 6 to have Bumblebee make a decision between green (go) and red (no-go) lights
void setup() {
for(int i =8;i<12;i++){
pinMode(i,OUTPUT);
}
pinMode(6,INPUT_PULLUP);
pinMode(7,INPUT_PULLUP);
pinMode(A0,INPUT);
}
void loop() {
if(digitalRead(6)==LOW){
for(int i=1;i<random(10,30);i++){
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
delay(150);
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
delay(150);
}
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(random(8,10),HIGH);
tone(A5,450);
delay(600);
noTone(A5);
}
}
//Tune Bumblebee's tone with the turn knob. Press Button 7 to play the tone
void setup() {
for(int i =8;i<12;i++){
pinMode(i,OUTPUT);
}
pinMode(6,INPUT_PULLUP);
pinMode(7,INPUT_PULLUP);
pinMode(A0,INPUT);
}
void loop() {
int pitch = analogRead(A0);
if(digitalRead(7)==LOW){
tone(A5,pitch);
}
else{
noTone(A5);
}
}