Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //LEDpins
- const int redLED = 9;
- const int greenLED = 10;
- const int blueLED = 11;
- //LED info
- int redLevel = 0;
- int greenLevel = 0;
- int blueLevel = 0;
- float counter = 0;
- float pi = 3.14159;
- //SENSORpins
- const int HALL = 2;
- const int BALL = 3;
- const int LIGHT = 4;
- //other ints
- int randomValue = 0;
- int brightness = 0;
- int fadeAmount = 2;
- void setup(){
- //LEDpins
- pinMode(redLED, OUTPUT);
- pinMode(greenLED, OUTPUT);
- pinMode(blueLED, OUTPUT);
- //Sensors
- pinMode(HALL, INPUT);
- pinMode(BALL, INPUT);
- pinMode(LIGHT, INPUT);
- }
- //Start loop
- void loop()
- {
- int MOOD = random(100);
- if (MOOD <=3) {
- // code for ANGRY here
- // set the brightness of pin RED:
- analogWrite(redLED, brightness);
- // change the brightness for next time through the loop:
- brightness = brightness + fadeAmount;
- // reverse the direction of the fading at the ends of the fade:
- if (brightness <= 0 || brightness >= 255) {
- fadeAmount = -fadeAmount;
- }
- // wait for 30 milliseconds to see the dimming effect
- delay(30);
- if (digitalRead (BALL) == HIGH && digitalRead (LIGHT) == HIGH)
- {
- void loop();
- }
- }
- if (MOOD > 3 && MOOD <= 10) {
- // code for CALM here
- analogWrite(greenLED, brightness);
- // change the brightness for next time through the loop:
- brightness = brightness + fadeAmount;
- // reverse the direction of the fading at the ends of the fade:
- if (brightness <= 0 || brightness >= 255) {
- fadeAmount = -fadeAmount;
- }
- // wait for 30 milliseconds to see the dimming effect
- delay(30);
- if (digitalRead (BALL) == HIGH)
- {
- void loop();
- }
- if (MOOD > 10 && MOOD <= 20) {
- // code for PLAY here
- analogWrite(blueLED, brightness);
- // change the brightness for next time through the loop:
- brightness = brightness + fadeAmount;
- // reverse the direction of the fading at the ends of the fade:
- if (brightness <= 0 || brightness >= 255)
- {
- fadeAmount = -fadeAmount;
- }
- // wait for 30 milliseconds to see the dimming effect
- delay(30);
- if (digitalRead (HALL) == HIGH)
- {
- void loop();
- }
- else
- {
- // code for blendColors here
- counter = counter + 1;
- redLevel = sin(counter/255)*1000;
- greenLevel = sin(counter/255 + pi*2/3)*1000;
- blueLevel = sin(counter/255 + pi*4/3)*1000;
- redLevel = map(redLevel,-1000,1000,0,255);
- greenLevel = map(greenLevel,-1000,1000,0,255);
- blueLevel = map(blueLevel,-1000,1000,0,255);
- analogWrite(redLED,redLevel);
- analogWrite(greenLED,greenLevel);
- analogWrite(blueLED,blueLevel);
- delay(10);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement