Hello.
I am having trouble converting some of my code from my Arduino setup to my new Maple Rev5 setup. I am using a combination of two boards, one Arduino and one Maple. The Maple board is the master, reads in input from the serial monitor, and sends the values to the Arduino slave.
The user begins by typing "s" and then the value they want to send. What used to work on the Arduino (s100 would send 100) now turns into (s100 is sending 7438)
I am not a very experienced computer programmer, so this is a bit beyond me.
Here is my code:
#include <Wire.h>
#define SLAVE_ID (2)
#define SEND_theSetting (11)
int theSetting = 100;
byte low_byte, high_byte;
byte command, argument[3], num_arg;
byte temp;
void setup()
{
// wait for the user to send a character
while (!SerialUSB.available());
// consume the character sent
SerialUSB.read();
}
void loop()
{
int i;
switch(command = SerialUSB.read())
{
case 's':
if( (num_arg = SerialUSB.available()) > 0 ) {
theSetting = 0;
for ( i=1; i<=num_arg; i++) { // convert characters to numeric value
theSetting += ((temp = (SerialUSB.read() - '0')) * pow(10.001,num_arg-i));
}
SerialUSB.print("Sending: ");
SerialUSB.println(theSetting,DEC); // echo calculated hr
low_byte = theSetting & 0xFF;
high_byte = theSetting >> 8;
Wire.beginTransmission(SLAVE_ID);
Wire.send(SEND_theSetting);
Wire.send(low_byte);
Wire.send(high_byte);
Wire.send(theSetting);
Wire.endTransmission();
break;
}
SerialUSB.println("Error: No value entered.");
break;
} // End switch
}
Thanks!!!