Go Down

Topic: ASCII to Number (Read 1 time) previous topic - next topic


I am using LiveCode to work with the Arduino Uno which has an LED attached and LC is sending ascii characters to the arduino which is looking for a number. I send 125 and it is reading:
Not 125.

How do I parse that together again? Or how do I send what the Arduino is looking for to get a 0 -255 for an Analog LED ?


Some simple code you can try for capturing your number string and converting to a number.

Code: [Select]
// zoomkat 8-6-10 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later

String readString;

void setup() {
        Serial.println("serial test 0021"); // so I can keep track of what is loaded

void loop() {

        while (Serial.available()) {
    if (Serial.available() >0) {
        char c = Serial.read();
        readString += c;}
      if (readString.length() >0) {
    int n;
    char carray[6]; //converting string to number
    readString.toCharArray(carray, sizeof(carray));
    n = atoi(carray);
    Serial.println(n); // print number
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

Go Up