void setup() { Serial.begin(9600); } void loop() { // Type in a number uint32_t number = readLong(); Serial.println(number); } /* Read a long off of the serial port and return. */ int32_t readLong() { char s[128]; /* 128 characters should be more than enough. */ readLine(s, 127); s[127] = '\0'; return atol(s); } /* Read a line (up to maxlen characters) off of the serial port. */ void readLine(char *s, uint8_t maxlen) { uint8_t i = 0; while(1) { while (Serial.available() == 0) { } /* Do nothing */ s[i] = Serial.read(); if (s[i] == '\0' || s[i] == '\n' || i == maxlen-1) break; i += 1; } }