Hello, so I am trying to make an LED (Flow_A) blink on a kegboard-mini Arduino shield, by sending a char from my iPhone, and I feel I am getting pretty close but for whatever reason the LED is not blinking, I think the problem lies in my Objective-C code :-/ but I am 100% sure that is the problem. Anyone here have any suggestions, on how I could troubleshoot this?
PaulS:
How is your phone connected to your Arduino? What code is running on the Arduino?
The iPhone is connected to the Arduino via serial port on the 30 pin dock connector, and the code running on the Arduino, is the pastie link posted in the first message.
Try delaying two seconds after opening the serial port before sending data to the arduino so you aren't talking to the bootloader when you send the data.
billroy:
Try delaying two seconds after opening the serial port before sending data to the arduino so you aren't talking to the bootloader when you send the data.
-br
How exactly would I do that? The Arduino is plugged in to the USB port on my computer, and is usually on, so I don't think I am talking to the bootloader, as I can send commands via the serial monitor fine. When I send "b" to blink the LED it blinks, and when I send "s" it stops blinking the LED. So I think the Arduino code is good, I think there is a problem with the Objective-C code somewhere
If you mean open the serial port wait 2 seconds then send the "b" command via Objective-C, I am all ears on how to do something like that.
When you first open the serial port, the Arduino resets and enters the boot loader to see if you want to upload a new program. It waits a couple seconds to see if the IDE is trying to upload, and if not it then times out and launches your Arduino C program.
During the time the bootloader is active, the first couple seconds after the serial port is opened, the bootloader receives any serial input you send. Not your program.
This ends up looking like "the arduino isn't hearing what I send to it", which is, I believe, the symptom you arrived here complaining about.
Try waiting a couple seconds in the iPhone code right after you open the serial port. There must be a way in Objective-C...
Well, I added the code below to the method posted above (tongue twister) and the LED is still not blinking even with a delay of three (3) seconds.
// delay sending serial data (tx) for a given time period
NSLog(@"start delay");
[NSThread sleepForTimeInterval:3.0];
NSLog(@"delay of 3 seconds ended");
I'm not an expert in iPhones or objective-C but can you do this just to confirm you have serial connection?
Connect Arduino to your computer. Open serial monitor at the speed you set iPhone serial port.
Connect iPhone TX to Arduino TX
Connect iPhone RX to Arduino RX
Remove Arduino's ATMEGA320 chip if you want
Write a simple program to send a few characters every second from iPhone.
See if these characters make it to the computer serial monitor.
liudr:
Connect iPhone TX to Arduino TX
Connect iPhone RX to Arduino RX
Isn't the iPhone TX suppose to be connected to the Arduino RX ?
No, you are going to use the Arduino as a USB TTL converter. So TX to TX and RX to RX. Your iPhone replaces the arduino in sending/receiving information.
liudr:
Connect iPhone TX to Arduino TX
Connect iPhone RX to Arduino RX
Isn't the iPhone TX suppose to be connected to the Arduino RX ?
No, you are going to use the Arduino as a USB TTL converter. So TX to TX and RX to RX. Your iPhone replaces the arduino in sending/receiving information.
hunh?
I think your thinking about something else. I just did a serial write, and printed the message on my iPhone screen, so I think you may be thinking about something else.
liudr:
Connect iPhone TX to Arduino TX
Connect iPhone RX to Arduino RX
Isn't the iPhone TX suppose to be connected to the Arduino RX ?
No, you are going to use the Arduino as a USB TTL converter. So TX to TX and RX to RX. Your iPhone replaces the arduino in sending/receiving information.
hunh?
I think your thinking about something else. I just did a serial write, and printed the message on my iPhone screen, so I think you may be thinking about something else.
I repeat, test your iPhone serial connection with a pc before you connect it to Arduino. Do whatever suits you cause you apparently didn't understand what I said was "testing iPhone serial with a PC".