First of all, make sure your LED is properly connected. Anode (longer pin) to PWM 11 port and cathode (shorter pin) to ground, also you may need to add a resistor between cathode and ground depending on LED Make sure you're writing to the right port from python (that FTDI cable is associated with in your OS) If you're not using FTDI cable with USB connector, make sure that all of the pins are connected to the right inputs What is the value of value in your example? Try arduino.
Write(chr(0xFF)) does LED stay lit?
First of all, make sure your LED is properly connected. Anode (longer pin) to PWM 11 port and cathode (shorter pin) to ground, also you may need to add a resistor between cathode and ground depending on LED. Make sure you're writing to the right port from python (that FTDI cable is associated with in your OS).
If you're not using FTDI cable with USB connector, make sure that all of the pins are connected to the right inputs. What is the value of value in your example? Try arduino.
Write(chr(0xFF)), does LED stay lit?
All works, it is only a code problem.. for the 4).. when I send chr(0xFF) the led stay off – frx08 Nov 30 '10 at 22:35 I've done an error.. with 0xFF stay on at the max.. reads the values in hexadecimal.. – frx08 Nov 30 '10 at 22:45 if I send (chr(0xff)) the led stays lit! I tried with other hex values and it's staying lit.. – fran Nov 30 '10 at 22:58.
I suspect that arduino.readline() waits for a newline, and you Arduino code never sends a newline. Hence the Python code blocks indefinitely after sending the first value.
I see in your comments that the LED works with the first character, but you don't see a change with the different characters. Definitely make sure you're sending ASCII characters that are significantly different from the previous characters, e.g. Send an ASCII 0 followed by an ASCII 255. Edit: Since you say the FadeLED example works, can you just take that example and add serial port functionality to it?
For example, only fade after a serial character is received. This will at least get you confident that the serial port and leds can coexist in code you write. Also, I assume you're using the FadeLED example from here.
If so, make sure you've set the correct pin number, as the reference code uses pin 9, but your sample code uses pin 11. Another Edit: You say you receive the characters back properly from the Arduino, but you're using the pySerial ReadLine function, which should block until it sees a newline, and I don't see anything in the Arduino code that would generate a newline that wasn't sent to it first.To eliminate the number of variables in the question, try using HyperTerminal or a similar COM port program to send bytes to the Arduino, rather than your Python program. For example, you can send space characters (ASCII 32) and '}' characters (ASCII 125), which should be different enough to create a visible difference in the LED.
– fran Nov 30 '10 at 23:12 using arduino. Read instead of arduino. Readline I get strange values!
– frx08 Nov 30 '10 at 23:21.
I would begin by establishing which side of the serial port harbours the problem. First of all, can you drive the LED using a hard-coded loop on the Arduino. Does the LED change its brightness as expected?
Once that's out of the way, can you make the Arduino do something visibly correct when sending stuff manually from a terminal app (e.g. The one built into the Arduino IDE). This may require changes to the Arduino code. Once that's working, I would then focus on the Python code, making sure you're talking to the right COM port etc.
In python we receive the response from arduino with the correct value that we have previously send.. but in this case analogwrite seems to not refresh – frx08 Nov 30 '10 at 22:26 Well I tried before simply turning on a led.. then I tried the fade example provided by arduino...everything is working.. now i'm trying to pass the desired data by python and here i'm failing. – fran Nov 30 '10 at 22:30 Can you successfully drive the Arduino from a terminal app? – aix Nov 30 '10 at 22:36 yes!
I can do it – frx08 Nov 30 '10 at 23:19.
The write value should send the value to my board through USB" If this is not a typo, then you can not use PySerial to access USB ports. There is pyUSB instead, and probably others.
1 the arduino uses a ftdi which will show up as a com port and is pyserial compatible – superfro Nov 30 '10 at 22:10.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.