Go Down

Topic: ASCII to Number (Read 967 times) 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

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131