Pages: [1]   Go Down
Author Topic: Motorbike 12V feeds to iPhone app  (Read 510 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I recently came off my motorbike and ripped the digital clocks off it. What I've managed to do is create an app on my iPhone that connects to the Arduino via Bluetooth.

The arduino has a couple of relays on it, and with a button on the app I can control the ignition of the bike. This is all up and running works fine.

I also have the 12 V feeds from the indicators, lights, neutral etc connected to the Arduino via individual L7805 regulators. when the Arduino recognises a 5 V high via one of these regulators. It sends the relevant command back to the iPhone so that it can display the correct image. This all works however after a couple of seconds the arduino resets itself.

Can anybody shed any light on this, all know of a better way of reducing the voltage from 12 V th an arduino acceptable one?

Many thanks

Spriggsy
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11197
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How is the Arduino itself powered?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi. I took an old car mobile phone charger apart. And used this to supply a clean 5 volts to the arduino and the blutooth module. The power supply doesn't fail though as the Bluetooth keeps its connection
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46240
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
This all works however after a couple of seconds the arduino resets itself.
This is not necessarily a hardware issue. It could be a software issue. So, what software are you running on the Arduino?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been reading up on voltage dividers. Maybe this is a better way to bring the voltage down to an arduino acceptable one.  Not 100% sure wether this is a better choice than the l7805 option. Can anyone shed any ideas on this approach?

Many thanks

Spriggsy
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11197
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi. I took an old car mobile phone charger apart. And used this to supply a clean 5 volts to the arduino and the blutooth module.

Is this actually supplying a smooth constant 5V to the Arduino? Batteries don't mind whether the supply is exactly the right voltage or completely smooth, but Arduinos do.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thinking about it maybe the 5v supply isnt 100%, this is the sort of device that im currently using.



and here is my code

Code:
#include <SoftwareSerial.h>
SoftwareSerial Bluetooth(2, 3); // RX, TX

String incomingString;
int relay1 = 4;
//relay2 = 5;

int ledState = LOW;

int alarmLed =  8;      // the number of the LED pin
int lowBeam = 9;
int highBeam = 10;
int right = 11;
int left = 12;
int neutral = 13;

int running = 0;

long previousMillis = 0;        // will store last time LED was updated
long interval = 1000;           // interval at which to blink (milliseconds)

int buttonState = 0;          // current state of the button being checked

int lastLState = 0;             // previous state of the button
int lastRState = 0;             // previous state of the button
int lastlowBeamState = 0;       // previous state of the button
int lasthighBeamState = 0;       // previous state of the button
int lastneutralState  = 0;
boolean alarm = true;


void setup() {
  pinMode(relay1, OUTPUT);
  digitalWrite(relay1, HIGH); 
  pinMode(alarmLed, OUTPUT);     
  pinMode(right, INPUT);
  pinMode(left, INPUT);
  pinMode(lowBeam, INPUT);
  pinMode(highBeam, INPUT);
  pinMode(neutral, INPUT);
  Serial.begin(9600);
  Bluetooth.begin(9600);
}


void loop() {
  // Check if there's incoming serial data.
  buttonState = digitalRead(right);
  if (buttonState != lastRState) {
    if (buttonState == HIGH) {
      Bluetooth.println("R ON");
    }
    else {
      Bluetooth.println("R OFF");
    }
  }
  lastRState = buttonState;

  buttonState = digitalRead(left);
  if (buttonState != lastLState) {
    if (buttonState == HIGH) {
      Bluetooth.println("L ON");
    }
    else {
      Bluetooth.println("L OFF");
    }
  }
  lastLState = buttonState;


  buttonState = digitalRead(lowBeam);
  if (buttonState != lastlowBeamState) {
    if (buttonState == HIGH) {
      Bluetooth.println("LOW ON");
    }
    else {
      Bluetooth.println("LOW OFF");
    }
  }
  lastlowBeamState = buttonState;

  buttonState = digitalRead(highBeam);
  if (buttonState != lasthighBeamState) {
    if (buttonState == HIGH) {
      Bluetooth.println("HIGH ON");
    }
    else {
      Bluetooth.println("HIGH OFF");
    }
  }
  lasthighBeamState = buttonState;

  buttonState = digitalRead(neutral);
  if (buttonState != lastneutralState) {
    if (buttonState == HIGH) {
      Bluetooth.println("N ON");
    }
    else {
      Bluetooth.println("N OFF");
    }
  }
  lastneutralState = buttonState;

  if (Bluetooth.available() > 0) {
    delay(10);
    char  inchar;   
    String text = "";
    while (Bluetooth.available()){
      inchar = Bluetooth.read();
      text = text + inchar;
    }
    text.toUpperCase();
    text.trim();
    Serial.println(text);
    if (text == "IGN ON") {
      digitalWrite(relay1, LOW);
      alarm = false;
    }
    if (text == "IGN OFF") {
      digitalWrite(relay1, HIGH); 
      alarm = true;
    }
  }


  unsigned long currentMillis = millis();
  // the following code gets called after every delay.
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;   
    if (alarm)
    {
      // if the LED is off turn it on and vice-versa:
      if (ledState == LOW)
        ledState = HIGH;
      else
        ledState = LOW;
      // set the LED with the ledState of the variable:
      digitalWrite(alarmLed, ledState);
    }
    else
    {
      digitalWrite(alarmLed,LOW);
    }
  }
}




this is all working fine if im not reading any of the 12volt feeds from the bike. i was riding the bike earlier on today ith no probs and no resetting.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think i may have narrowed it down to the Bluetooth.print command.

if i don't send many messages at a time it runs fine. when constantly sending it crashes the chip.  although it runs fine if powered from USB,

anyone else ever run into anything like this or have any suggestions?
Logged

Pages: [1]   Go Up
Jump to: