Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Blink
- Turns on an LED on for one second, then off for one second, repeatedly.
- Most Arduinos have an on-board LED you can control. On the Uno and
- Leonardo, it is attached to digital pin 13. If you're unsure what
- pin the on-board LED is connected to on your Arduino model, check
- the documentation at http://arduino.cc
- This example code is in the public domain.
- modified 8 May 2014
- by Scott Fitzgerald
- */
- int led1 = 13;
- int led2 = 12;
- int led3 = 11;
- int led4 = 10;
- int led5 = 9;
- int led6 = 8;
- int buzzer = 3;
- // the setup function runs once when you press reset or power the board
- void setup() {
- // initialize digital pin 13 as an output.
- pinMode(led1, OUTPUT);
- pinMode(led2, OUTPUT);
- pinMode(led3, OUTPUT);
- pinMode(led4, OUTPUT);
- pinMode(led5, OUTPUT);
- pinMode(led6, OUTPUT);
- pinMode(buzzer, OUTPUT);
- }
- // the loop function runs over and over again forever
- void loop() {
- int lightSensor = digitalRead(7);
- digitalWrite(led4, !lightSensor);
- analogPitch();
- analogBrightness();
- }
- void singleLightBlink(int light) {
- digitalWrite(light, HIGH); // turn the LED on (HIGH is the voltage level)
- delay(1000); // wait for a second
- digitalWrite(light, LOW); // turn the LED off by making the voltage LOW
- delay(1000);
- }
- void lightSequence(int light, int delayTimer) {
- flash(light, 50);
- delay(500);
- flash(light, 50);
- delay(500);
- flash(light, 50);
- delay(100);
- flash(light, 50);
- delay(500);
- flash(light, 50);
- }
- void lightSequence2(int delayTimer) {
- flash(led1);
- delay(delayTimer);
- flash(led2);
- delay(delayTimer);
- flash(led3);
- delay(delayTimer);
- flash(led4);
- delay(delayTimer);
- flash(led5);
- delay(delayTimer);
- flash(led6);
- delay(delayTimer);
- }
- void analogPitch() {
- digitalWrite(led2, HIGH);
- int pitch = analogRead(A5);
- tone(buzzer, pitch, 20);
- delay(10);
- }
- void analogBrightness() {
- int lightSensor = analogRead(A5);
- analogWrite(led6, lightSensor);
- }
- void flash (int light) {
- digitalWrite(light, HIGH);
- delay(50);
- digitalWrite(light, LOW);
- }
- void flash(int light, int liveTime) {
- digitalWrite(light, HIGH);
- delay(liveTime);
- digitalWrite(light, LOW);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement