I have the following code for an Arduino sketch:
#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
static FILE lcdout = {0} ;
static
I did this one:
unsigned char buffer[32];
void setup() {
serial.begin();
}
void loop() {
if(serial.available()) {
int size = serial.read(buffer);
if (size!=0) {
//serial.write((const uint8_t*)buffer, size);
int bright = atoi((char *) buffer);
//int final = ((unsigned int)buffer[0]);
//int final = bright -'0';
serial.write(bright);
serial.write('\n');
}
}
serial.poll();
}
and now i get an ascii char when i send a value from 0-255 through the usb. I should find a way to convert the ascii char to int.
e.g i type 65 and it prints A