Ok.. This is great. But I tried this froma Windows 8.1 computer running Math 10. I replace the Arduino code with the AnalogRead potentiometer sample sketch.
/*
ReadAnalogVoltage
Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
Serial.println(voltage);
}
I got the following error
serial = DeviceOpen["Serial", {"COM3", "BaudRate" -> 9600}];
ping := Module[{x}, DeviceWriteBuffer[serial, {"5"}];
x = DeviceReadBuffer[serial][[1; 1]]]
data = Transpose@Table[ping, {i, 120}]
I got a lot of errors..
During evaluation of In[40]:= Part::partw: Part 1 of {} does not exist. >>
During evaluation of In[40]:= Part::partw: Part 1 of {} does not exist. >>
During evaluation of In[40]:= Part::partw: Part 1 of {} does not exist. >>
During evaluation of In[40]:= General::stop: Further output of Part::partw will be suppressed during this calculation. >>
During evaluation of In[40]:= Transpose::nmtx: The first two levels of {13,{}[[1]],53,{}[[1]],46,{}[[1]],13,{}[[1]],{}[[1]],{}[[1]],{}[[1]],10,{}[[1]],{}[[1]],48,{}[[1]],{}[[1]],53,{}[[1]],{}[[1]],10,{}[[1]],{}[[1]],48,{}[[1]],{}[[1]],46,{}[[1]],{}[[1]],10,{}[[1]],{}[[1]],48,{}[[1]],{}[[1]],48,{}[[1]],{}[[1]],53,{}[[1]],{}[[1]],13,{}[[1]],{}[[1]],{}[[1]],48,{}[[1]],{}[[1]],10,{}[[1]],<<70>>} cannot be transposed. >>
Out[42]= Transpose[{13, {}[[1]], 53, {}[[1]], 46, {}[[1]],
13, {}[[1]], {}[[1]], {}[[1]], {}[[1]], 10, {}[[1]], {}[[1]],
48, {}[[1]], {}[[1]], 53, {}[[1]], {}[[1]], 10, {}[[1]], {}[[1]],
48, {}[[1]], {}[[1]], 46, {}[[1]], {}[[1]], 10, {}[[1]], {}[[1]],
48, {}[[1]], {}[[1]], 48, {}[[1]], {}[[1]], 53, {}[[1]], {}[[1]],
13, {}[[1]], {}[[1]], {}[[1]], 48, {}[[1]], {}[[1]],
10, {}[[1]], {}[[1]], 48, {}[[1]], {}[[1]], 48, {}[[1]], {}[[1]],
46, {}[[1]], {}[[1]], 10, {}[[1]], {}[[1]], 48, {}[[1]], {}[[1]],
53, {}[[1]], {}[[1]], 53, {}[[1]], {}[[1]], 13, {}[[1]], {}[[1]],
48, {}[[1]], {}[[1]], {}[[1]], 10, {}[[1]], {}[[1]],
48, {}[[1]], {}[[1]], 48, {}[[1]], {}[[1]], 46, {}[[1]], {}[[1]],
10, {}[[1]], {}[[1]], 48, {}[[1]], {}[[1]], 53, {}[[1]], {}[[1]],
13, {}[[1]], {}[[1]], {}[[1]], 13, {}[[1]], {}[[1]],
46, {}[[1]], {}[[1]], 10, {}[[1]], {}[[1]], 48, {}[[1]], {}[[1]],
46, {}[[1]], {}[[1]], 46}]
In[30]:= data
Out[30]= Transpose[{{48, 13, 10}, {}[[1 ;; 3]], {48, 48, 13}, {}[[
1 ;; 3]], {10, 53, 46}, {}[[1 ;; 3]], {10, 53, 46}, {}[[
1 ;; 3]], {}[[1 ;; 3]], {48, 48, 13}, {}[[1 ;; 3]], {48, 13,
10}, {}[[1 ;; 3]], {}[[1 ;; 3]], {48, 13, 10}, {}[[1 ;; 3]], {}[[
1 ;; 3]], {46, 48, 48}, {}[[1 ;; 3]], {}[[1 ;; 3]], {10, 53,
46}, {}[[1 ;; 3]], {}[[1 ;; 3]], {13, 10, 53}, {}[[1 ;; 3]], {}[[
1 ;; 3]], {48, 48, 13}, {}[[1 ;; 3]], {}[[1 ;; 3]], {53, 46,
48}, {}[[1 ;; 3]], {}[[1 ;; 3]], {13, 10, 53}, {}[[1 ;; 3]], {}[[
1 ;; 3]], {46, 48, 48}, {}[[1 ;; 3]], {}[[1 ;; 3]], {46, 48,
48}, {}[[1 ;; 3]], {}[[1 ;; 3]], {}[[1 ;; 3]], {10, 53, 46}, {}[[
1 ;; 3]], {}[[1 ;; 3]], {48, 13, 10}, {}[[1 ;; 3]], {}[[
1 ;; 3]], {46, 48, 48}, {}[[1 ;; 3]], {}[[1 ;; 3]], {13, 10,
53}, {}[[1 ;; 3]], {}[[1 ;; 3]], {48, 48, 13}, {}[[1 ;; 3]], {}[[
1 ;; 3]], {48, 48, 13}, {}[[1 ;; 3]], {}[[1 ;; 3]], {53, 46,
48}, {}[[1 ;; 3]], {}[[1 ;; 3]], {13, 10, 53}, {}[[1 ;; 3]], {}[[
1 ;; 3]], {46, 48, 48}, {}[[1 ;; 3]], {}[[1 ;; 3]], {}[[
1 ;; 3]], {46, 48, 48}, {}[[1 ;; 3]], {}[[1 ;; 3]], {10, 53,
46}, {}[[1 ;; 3]], {}[[1 ;; 3]], {46, 48, 48}, {}[[1 ;; 3]], {}[[
1 ;; 3]], {46, 48, 48}, {}[[1 ;; 3]], {}[[1 ;; 3]], {13, 10,
53}, {}[[1 ;; 3]], {}[[1 ;; 3]], {48, 48, 13}, {}[[1 ;; 3]], {}[[
1 ;; 3]], {48, 48, 13}, {}[[1 ;; 3]], {}[[1 ;; 3]], {53, 46,
48}, {}[[1 ;; 3]], {}[[1 ;; 3]], {48, 13, 10}, {}[[1 ;; 3]], {}[[
1 ;; 3]], {}[[1 ;; 3]], {46, 48, 48}, {}[[1 ;; 3]], {}[[
1 ;; 3]], {10, 53, 46}, {}[[1 ;; 3]], {}[[1 ;; 3]], {10, 53,
46}, {}[[1 ;; 3]], {}[[1 ;; 3]], {48, 13, 10}, {}[[1 ;; 3]], {}[[
1 ;; 3]], {53, 46, 48}, {}[[1 ;; 3]], {}[[1 ;; 3]], {13, 10,
53}, {}[[1 ;; 3]], {}[[1 ;; 3]], {48, 48, 13}, {}[[1 ;; 3]], {}[[
1 ;; 3]], {48, 48, 13}}]
Attachments: