hello, have problem source code of sundial.
i want use key switch bypass open gps based box. idea was, give 5v via key switch digital pin 0 on arduino , pushing main button start box, servo opens. tried many ways don't find solution.
i hope can me. sure simple seems not cup of tea^^
here source code:
my idea in "void setup();" add this:
best greetings kevin
i want use key switch bypass open gps based box. idea was, give 5v via key switch digital pin 0 on arduino , pushing main button start box, servo opens. tried many ways don't find solution.
i hope can me. sure simple seems not cup of tea^^
here source code:
code: [select]
#include <pwmservo.h>
#include <softwareserial.h>
#include <tinygps.h>
#include <eeprom.h>
#include <liquidcrystal.h>
//hier nichts verändern!
// -------------------------------------------------------------------
static const int servo_closed_angle = 95; // degrees (0-180)
static const int servo_open_angle = 135; // degrees (0-180)
//hier kannst du deine koordinaten und den radius eingeben
// -------------------------------------------------------------------
static const float dest_latitude = 47.642154; // degrees (-90 90)
static const float dest_longitude = 9.762664; // degrees (-180 180)
static const int radius = 100; // meters
static const int lcd_contrast = 50; // (0-255)
//hier nichts verändern!
// -------------------------------------------------------------------
static const int def_attempt_max = 50;
static const int eeprom_offset = 100;
static const int gps_rx_pin = 4, gps_tx_pin = 3;
static const int lcd_enable_pin = 7, lcd_rs_pin = 5, lcd_rw_pin = 8;
static const int lcd_db4_pin = 14, lcd_db5_pin = 15, lcd_db6_pin = 16, lcd_db7_pin = 17;
static const int lcd_contrast_pin = 6;
static const int pololu_switch_pin = 12;
static const int servo_control_pin = 9;
static const int led_pin = 2;
static const int piezo_pin = 11;
static softwareserial ss(gps_rx_pin, gps_tx_pin);
static liquidcrystal lcd(lcd_rs_pin, lcd_rw_pin, lcd_enable_pin, lcd_db4_pin, lcd_db5_pin, lcd_db6_pin, lcd_db7_pin);
static tinygps tinygps;
static int attemptcounter;
static pwmservo servo;
void setup()
{
pinmode(pololu_switch_pin, output);
digitalwrite(pololu_switch_pin, low);
servo.attach(servo_control_pin);
serial.begin(115200);
ss.begin(4800);
pinmode(lcd_contrast_pin, output);
analogwrite(lcd_contrast_pin, lcd_contrast);
lcd.begin(16, 2);
pinmode(led_pin, output);
digitalwrite(led_pin, high);
servo.write(servo_closed_angle);
attemptcounter = eeprom.read(eeprom_offset);
if (attemptcounter == 0xff)
attemptcounter = 0;
++attemptcounter;
msg(lcd, " kevin & ", " nadja's ", 1500);
msg(lcd, " adventure ", " box! ", 2000);
if (attemptcounter >= def_attempt_max)
{
msg(lcd, " sorry, keine ", " weiteren ", 2000);
msg(lcd, " versuche ", " erlaubt! ", 2000);
msg(lcd, " bitte besitzer ", " kontaktieren! ", 2000);
msg(lcd, " telefon: ", " 0152-52564613 ", 5000);
msg(lcd, "kevinmeister89@ ", " googlemail.com ", 5000);
msg(lcd, " vielen dank! ", "", 2000);
poweroff();
}
msg(lcd, "das ist versuch ", "", 2000);
lcd.clear();
lcd.setcursor(3, 0);
lcd.print(attemptcounter);
lcd.print(" von ");
lcd.print(def_attempt_max);
delay(2000);
eeprom.write(eeprom_offset, attemptcounter);
msg(lcd, " (((suche))) ", " (((gps..))) ", 0);
}
void loop()
{
if (ss.available() && tinygps.encode(ss.read()))
{
float lat, lon;
unsigned long fixage;
tinygps.f_get_position(&lat, &lon, &fixage);
if (fixage != tinygps::gps_invalid_age)
{
chirp(true);
float distance_meters = tinygps::distance_between(lat, lon, dest_latitude, dest_longitude);
if (distance_meters <= radius)
{
msg(lcd, " zugriff ", " erlaubt! ", 2000);
eeprom.write(eeprom_offset, 0);
servo.write(servo_open_angle);
}
else
{
lcd.clear();
lcd.setcursor(0, 0);
lcd.print(" entfernung ");
lcd.setcursor(6, 1);
if (distance_meters < 5000)
{
lcd.print((int)distance_meters);
lcd.print("m");
}
else
{
lcd.print((int)(distance_meters / 1000));
lcd.print("km");
}
delay(4000);
msg(lcd, " kein ", " zugriff! ", 2000);
}
poweroff();
}
}
if (millis() >= 300000)
poweroff2();
}
void poweroff()
{
chirp(false);
msg(lcd, " schalte aus! ", "", 2000);
lcd.clear();
digitalwrite(pololu_switch_pin, high);
delay(300000);
servo.write(servo_open_angle);
eeprom.write(eeprom_offset, 0);
delay(10000);
servo.write(servo_closed_angle);
exit(1);
}
void poweroff2()
{
chirp(false);
msg(lcd, " kein signal! ", "", 2000);
msg(lcd, " schalte aus! ", "", 2000);
lcd.clear();
digitalwrite(pololu_switch_pin, high);
delay(300000);
servo.write(servo_open_angle);
eeprom.write(eeprom_offset, 0);
delay(10000);
servo.write(servo_closed_angle);
exit(1);
}
void msg(liquidcrystal &lcd, const char *top, const char *bottom, unsigned long del)
{
lcd.clear();
lcd.setcursor(0, 0);
lcd.print(top);
lcd.setcursor(0, 1);
lcd.print(bottom);
delay(del);
}
static void chirp(bool up)
{
static const int = 1760;
static const int e = 2637;
static const int cs = 2218;
static const int duration = 100;
int tone1 = ? : e;
int tone2 = ? e : a;
ss.end();
tone(piezo_pin, tone1, duration);
delay(duration);
notone(piezo_pin);
tone(piezo_pin, tone2, duration);
delay(duration);
notone(piezo_pin);
ss.begin(4800);
}
my idea in "void setup();" add this:
code: [select]
void setup() {
pinmode(53, output);
pinmode(bypass_input,input);
servo.attach(servo_pin);
servo.write(closeposition);
gpsserial.begin (9600); // connect gps sensor
// set lcd's number of columns , rows:
lcd.begin(16, 2);
// print message lcd.
val = digitalread(bypass_input);
if (val == high){
printtolcd("bypass enabled","(2000)");
servo.write(openposition);
delay(500);
poweroff();
}
best greetings kevin
quote
my idea was, give 5v via key switch digital pin 0 on arduinoso, don;t want use serial?
quote
my idea in "void setup();" add this:so, want able open box when arduino resets?
code: [select]
printtolcd("bypass enabled","(2000)");
what possible reason there send "(2000)" second argument mysterious function?
Arduino Forum > Using Arduino > Programming Questions > Bypass Key Switch
arduino
Comments
Post a Comment