Hey all,
quick question came up in discussion.
here is the example.
i have a standalone device that can run off an FTDI for programming, and also off USB VCC / GND.
is there a way in the Arduino IDE to detect if the Serial is available or not. Meaning, if i have an FTDI plugged in, turn and RGB led green, and when i am only in USB to turn it red.
i am familiar with how to run the leds and such, my question is more about detecting if the FTDI is plugged in, or if the USB for VCC/GND only.
thanks in advance
Only if some software on the PC is attached to the USB FTDI comm port. Such a PC program could respond to an Arduino sent enquiry and acknowledge it by sending something back to the Arduino.
not too sure i understand the PC part.
allow me to elaborate.
currently, the USB device is a gamepad. the standalone arduino simply read the inputs from the gamepad with wires soldered from the dpad and buttons to digital inputs... ...but. there are enough input lines that i needed to use D0 and D1 so the RX and TX lines are tied up during USB mode, but when in FTDI programming mode i would like the USB mode code not to run so i can interface with Processing.
Hope that clears things up.
Hope that clears things up.
No, not for me. But I'm old and slow and work better with electrical schematic drawings and such rather then written words trying to describe details of a system.
However I did see you have a question about having enough pins? Are you using the analog input pins also, as they can be used as normal digital input or output pins?
Lefty
there are enough input lines that i needed to use D0 and D1 so the RX and TX lines are tied up during USB mode
As lefty says it seems like your fundamental problem is not enough "digital" IO, but again as lefty says you can use the analogue pins for this.
If they are all used as well then use a MUX to get a few extra IPs of a shift register to add some OPs, either way will free up some pins.
Rob
If you leave Rx/Tx free from the gamepad, then you plug the PC into the USB port it should reset the arduino - if you have a normal bootloader installed it will watch for the start of programming type commands for instance, if not there it will start your sketch.
I think that answers what you are after. You could have your sketch turn an LED whatever color you want when it starts.
Thanks all for the responses. So it seems that if I am using all only including analog as digital 14 - 19 sounds like there is no easy way to detect if serial available is connected or f the arduino is just receiving power supply and ground. I thought for sure there was some trick.
Yeah, the hardware needs to see the line change from 0 to 1 to call that a start bit. If nothing is being transmitted in, there is no transition.
Maybe if you pull the Rx pin high, it might read in as 0xFF all the time, and then when a real transmitter is connected it would hold the line low until it went high for a start bit.
Which FTDI cable? If it's the 6-pin version you could run say the 5v signal to an input with a pull down resistor. Cable plugged in, 5v on input, no cable 0v.
This assumes that you aren't using the 5v from the cable to power your board. If you are then add a diode.
Rob