Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- AnalogReadSerial
- Reads an analog input on pin 0, prints the result to the Serial Monitor.
- Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
- Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
- This example code is in the public domain.
- http://www.arduino.cc/en/Tutorial/AnalogReadSerial
- */
- const int LED_PIN = 8;
- const int BUZZER_PIN = 3;
- const int DELAY_CRTA = 1000;
- const int DELAY_TACKA = 100;
- char poruka[]="SOS";
- char morze[26][5]={
- ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....",
- "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.",
- "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-",
- "-.--", "--.."
- };
- void beep(unsigned char delayms) { //creating function
- analogWrite(BUZZER_PIN, 20); //Setting pin to high
- delay(delayms); //Delaying
- analogWrite(BUZZER_PIN ,0); //Setting pin to LOW
- delay(delayms); //Delaying
- }
- // the setup routine runs once when you press reset:
- void setup() {
- Serial.begin(9600);
- pinMode(LED_PIN,OUTPUT);
- pinMode(BUZZER_PIN, OUTPUT); //Set buzzerPin as output
- beep(50); //Beep
- beep(50); //Beep
- delay(1000); //Add a little delay
- }
- void epilepsija(int pin){
- for(int i=0;i<10;i++){
- delay(40);
- beep(40);
- digitalWrite(pin,HIGH);
- delay(40);
- beep(40);
- digitalWrite(pin,LOW);
- }
- }
- // the loop routine runs over and over again forever:
- void loop() {
- for(int i=0;i<sizeof(poruka)-1;i++){
- char slovo = poruka[i];
- Serial.print(slovo);
- Serial.print(':');
- for(int j=0; morze[slovo - 'A'][j]!='\0';j++){
- char znak = morze[slovo - 'A'][j];
- Serial.print(znak);
- digitalWrite(LED_PIN,HIGH);
- if(znak=='.')
- beep(DELAY_TACKA);
- else
- beep(DELAY_CRTA);
- digitalWrite(LED_PIN,LOW);
- delay(200);
- }
- Serial.println();
- delay(200);
- }
- Serial.println(' ');
- epilepsija(LED_PIN);
- delay(2000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement