So in our project we use Tx and Rx for the communication network at our Uni. The prof wants us to use two digital pins for debugging.
So I have:
Rx on 5
Tx on 6
I now want to output data to the Tx pin, that I am reading from an analog pin.
So I write
val = analogRead(A0);
analogWrite(6, val) ;
I don't know if this is right. I basically want to measure voltage and write it to pin 6. I know that the read values go from 0 to 1023 and the written values from 0 to 255. So do I have any conversion to make? On the oscilloscope I see that there are values being transmitted. Before when I was using digitalWrite I only got a HIGH value.
Then I want to read the data on Linux and write it in a file. First I have tried
cat -v /dev/ttyUSB0
to see if there is anything being received, but I only get a:
^@^@
Can anyone help me with this or recommend tutorials?
In the end I want to output the values every 30 seconds and write them to a file. I know I will have to program a script then, but at first I want to understand the basics.
I can't use a USB cable because it would conflict with the battery. I want to create a State of Charge indicator and therefore discharge the battery until the Arduino dies. I output the data on pin 6 and have to work with that.
Well, I could but the Prof wants me to do it like this. Rx and Tx are already reserved for another communication port. I need to program my own script to read and process the raw data. I am writing a script in python at the moment.
I now need to know what is actually happening here. This is my sketch so far:
Since the value range is an integer from 0 to 1023, what exactly happens when I use analogWrite() to send it to pin 6? Is it being converted to a 0 to 255 value?
gunjah292:
Well, I could but the Prof wants me to do it like this.
Can you post the precise terms of the Professor's requirement.
In your Original Post you say "The prof wants us to use two digital pins for debugging" and my suggestion to use SoftwareSerial and a USB-TTL converter complies 100% with that,