• bilgi@etkinbot.com
  • +90 850 885 2580
TR EN

Joystick ile Ses(Buzzer) Kontrolü

Gerekli Malzemeler

  • Etkinbot V1
  • Arduino Joystick Modülü

MBlock Kodları



Arduino Kodları

#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>

#include "etkinbot.h"

double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
EtkinClass etkinbot;

void setup(){
    pinMode(8,OUTPUT);
}

void loop(){
    if(etkinbot.joystick(1)){
        tone(8,262,500); // write to buzzer
        delay(500);
    }else{
        if(etkinbot.joystick(1)){
            tone(8,294,500); // write to buzzer
            delay(500);
        }else{
            if(etkinbot.joystick(1)){
                tone(8,330,500); // write to buzzer
                delay(500);
            }else{
                tone(8,349,500); // write to buzzer
                delay(500);
            }
        }
    }
    _loop();
}

void _delay(float seconds){
    long endTime = millis() + seconds * 1000;
    while(millis() < endTime)_loop();
}

void _loop(){
}