Flashing/beeping

Ok. So I started with very simple programs first to familiarize myself with the whole process of creating/compiling and uploading to the board.

One of the simplest that came into my mind was a program for flashing LED or beeping sound (can be later integrated to more difficult and complex programs…)

I have only connected the sound beeper to the board (digital output pin).

Blocks:
- drag an “on for” block and select your digital pin number
- drag a “variable” block next to it and set the variable – that will be the time delay (in miliseconds) between beeps/flashes (I chose 500 – 1/2 of a second)

The code looks like this:

int val= 0;
int compare=0;
int Variable31=500;
int Pin7 = 7;
void setup(){
pinMode(Pin7, OUTPUT);

}
void loop(){
digitalWrite(Pin7, HIGH);
delay(Variable31);
digitalWrite(Pin7, LOW);
delay(Variable31);

}

« »

2 Responses to “Flashing/beeping”

Tomas says:

Yes it did….

The code was following:

int val= 0;
int compare=0;
int Variable31=500;
int Pin7 = 7;
void setup(){
pinMode(Pin7, OUTPUT);

}
void loop(){
digitalWrite(Pin7, HIGH);
delay(Variable31);
digitalWrite(Pin7, LOW);
delay(Variable31);

}

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>