Pages: [1]   Go Down
Author Topic: No serial communication working with Romeo V2 board  (Read 397 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, I have a Romeo V2 board and I want to use serial communication from Romeo to computer (via USB).
My SW is simple: when switch are pushed, a led lights and a message should appear on the Serial screen.
The compilation works, the led switch when I push each buttons (OK), but I do not see any message on the serial screen... (my IDE is 1.0.3). I see the port of the board (COMX) => OK, I define the type of board and the serial port in TOOL. but still no message...
Please, can someone help me?
Help!

Code:
#include <SoftwareSerial.h>
char msgs[5][15] = {
"Right Key OK ",
"Up Key OK ",
"Down Key OK ",
"Left Key OK ",
"Select Key OK"};
char start_msg[15] = {
"Start loop "};
int adc_key_val[5] ={
30, 150, 360, 535, 760 };
int NUM_KEYS = 5;
int adc_key_in;
int key=‐1;
int oldkey=‐1;
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
delay(1);
/*Print that we made it here*/
/* Serial.println(start_msg);*/
Serial.println(NUM_KEYS);
delay(1);
}
void loop()
{
digitalWrite(13, LOW);
adc_key_in = analogRead(0); // read the value from the sensor
/* get the key */
key = get_key(adc_key_in); // convert into key press
if (key != oldkey) { // if keypress is detected
delay(50); // wait for debounce time
adc_key_in = analogRead(0); // read the value from the sensor
key = get_key(adc_key_in); // convert into key press
if (key != oldkey) {
oldkey = key;
digitalWrite(13, HIGH);
delay(1000);
if (key =0){
Serial.println(adc_key_in, DEC);
delay(1);
Serial.println(msgs[key]);
delay(1);
}
}
}
}
// Convert ADC value to key number
int get_key(unsigned int input)
{
int k;
for (k = 0; k < NUM_KEYS; k++)
{
if (input < adc_key_val[k])
{
return k;
}
}
if (k = NUM_KEYS)
k = ‐1; // No valid key pressed
return k;
}


Moderator edit: [code] [/code] tags added.
« Last Edit: February 28, 2013, 12:38:46 am by Coding Badly » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12283
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


It would be most helpful if you used auto-format in the IDE.

Code:
if (key =0){
...oops.

Code:
if (k = NUM_KEYS)
...oops.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46029
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use
of
the
tab
key
once
in
a
while
is
a
good
thing.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't understand this stuff:

Code:
}
}
}
}
Logged

Pages: [1]   Go Up
Jump to: