Group Abstract Group Abstract

Message Boards Message Boards

Arduino and Mathematica 10 (Can't make a ListPlot from an analogread)

Posted 12 years ago
Attachments:
6 Replies

Thank you!!

Hi everybody, first of all thanks for your time and help, you are very helpful!!!. Ian, your code is correct, but this not exactly what I was looking for. I want to make a ListPlot while receiving the information, not when I press “Shift+enter”, so I tried with your code and the “Dynamic” option but I cannot do it. On the other hand, also I would like to make severals Plots corresponding to several sensors in real time.

Again, thanks for your help.

Fernando.

POSTED BY: Ian Johnson

Thank you Ian. Would you mind posting your complete Arduino sketch and Mathematica notebook?

I think that the problem here is that the Arduino is spitting out over serial something that looks like "{ 123, 1233} \n { 456, 789 } \n " so when you go to plot that, it doesn't automatically evaluate to the list of lists that you want, and stays as Vitaliy points out in String format. So if you split it by the newline character and use ToExpression I think that should work for you.

When I uploaded your sketch to my Arduino, the following worked for me.

rawdata = DeviceReadBuffer["Serial"]
points = ToExpression /@ StringSplit[FromCharacterCode[rawdata], "\n"]
ListLinePlot[points]

That gave me what I think you are looking for.

Plot from the Arduino

Ian

POSTED BY: Ian Johnson

FromCharacterCode returns a string, not (lists of) numbers. ListPlot cannot plot strings.

POSTED BY: Vitaliy Kaurov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard