mirror of
https://github.com/LinoSchmidt/RoboterArm.git
synced 2026-03-21 02:31:16 +01:00
add buzzer
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <Servo.h>
|
#include <Servo.h>
|
||||||
|
#include <EEPROM.h>
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
//--------------------------> Einstellungen <-----------------------
|
//--------------------------> Einstellungen <-----------------------
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
//Servos
|
||||||
#define DrehungPin 9
|
#define DrehungPin 9
|
||||||
#define ArmPin 10
|
#define ArmPin 10
|
||||||
#define OberarmPin 11
|
#define OberarmPin 11
|
||||||
@@ -28,6 +30,7 @@
|
|||||||
#define Oberarm_Start 111
|
#define Oberarm_Start 111
|
||||||
#define Hand_Start 0
|
#define Hand_Start 0
|
||||||
|
|
||||||
|
//Joysticks
|
||||||
#define joystick_LX_Pin 0
|
#define joystick_LX_Pin 0
|
||||||
#define joystick_LY_Pin 1
|
#define joystick_LY_Pin 1
|
||||||
#define joystick_RX_Pin 2
|
#define joystick_RX_Pin 2
|
||||||
@@ -46,9 +49,17 @@
|
|||||||
#define joystick_MaxSpeed 10
|
#define joystick_MaxSpeed 10
|
||||||
#define joystick_MinSpeed 1
|
#define joystick_MinSpeed 1
|
||||||
|
|
||||||
|
//Timing
|
||||||
#define LoopTime 25
|
#define LoopTime 25
|
||||||
#define TimeToAutoplay 500
|
#define TimeToAutoplay 500
|
||||||
#define TimeToDetach 80
|
#define TimeToDetach 80
|
||||||
|
#define Calibration_TimeToMiddle 3000
|
||||||
|
|
||||||
|
//Buzzer
|
||||||
|
#define BuzzerPin 8
|
||||||
|
#define Buzzer_CalibrationHGIH 2
|
||||||
|
#define Buzzer_CalibrationLOW 1
|
||||||
|
#define Buzzer_ShortTon 1
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
@@ -68,6 +79,17 @@ void setup(){
|
|||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
pinMode(joystick_button_Pin, INPUT_PULLUP);
|
pinMode(joystick_button_Pin, INPUT_PULLUP);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void calibrate(){
|
||||||
|
tone(BuzzerPin, Buzzer_CalibrationHGIH);
|
||||||
|
for(int loT = Buzzer_CalibrationHGIH; loT > Buzzer_CalibrationLOW; loT--){
|
||||||
|
tone(BuzzerPin, loT);
|
||||||
|
delay(Calibration_TimeToMiddle / (Buzzer_CalibrationHGIH - Buzzer_CalibrationLOW));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void joystickButtonPress(){
|
void joystickButtonPress(){
|
||||||
@@ -118,6 +140,7 @@ void joystickButtonPress(){
|
|||||||
Serial.println(String(Code[0]) + String(Code[1]) + String(Code[2]) + String(Code[3]) + String(Code[4]) + " Len:" + String(CodeLenght));
|
Serial.println(String(Code[0]) + String(Code[1]) + String(Code[2]) + String(Code[3]) + String(Code[4]) + " Len:" + String(CodeLenght));
|
||||||
if(Code[0] == 0 && Code[1] == 1 && Code[2] == 0 && Code[3] == 1 && Code[4] == 0 && CodeLenght == 4){
|
if(Code[0] == 0 && Code[1] == 1 && Code[2] == 0 && Code[3] == 1 && Code[4] == 0 && CodeLenght == 4){
|
||||||
Serial.println("Calibrate...");
|
Serial.println("Calibrate...");
|
||||||
|
calibrate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user