Asked
— Edited
Hey everyone,
I am using arduino's in my coding class, and have tried to communicate with it via the ez-b over serial. I seem to be able to receive, but I am not able to send it seems.
I am using the serial terminal for ez-b, as well as the serial monitor in the arduino ide. When I send a string, the ez-b recieves, but I cannot seem to get the arduino to recieve from the ez-b.
I was wondering if anyone who has been doing this can shed some light on it for me, as I am still trying to learn the ropes.
Arduino code:
#include
Servo servo1; servo servo2;
void setup() {
pinMode(1,OUTPUT);
servo1.attach(14); //analog pin 0
//servo1.setMaximumPulse(2000);
//servo1.setMinimumPulse(700);
servo2.attach(15); //analog pin 1
Serial.begin(9600);
Serial.println("Ready");
}
void loop() {
static int v = 0;
if ( Serial.available()) {
char ch = Serial.read();
Serial.println("y");
switch(ch) {
case '0'...'9':
v = v * 10 + ch - '0';
break;
case 's':
servo1.write(v);
v = 0;
break;
case 'w':
servo2.write(v);
v = 0;
break;
case 'd':
servo2.detach();
break;
case 'a':
servo2.attach(15);
break;
}
}
}
Thanks guys. Dylan
Did you configured the serial monitor with no "line ending" window bottom right ?
I've tried multiple ways, might be worth a second shot.
You can click in the terminal window and type, rather than typing words and pressing send.
Are you sure the wire is connected to the correct port?
If it receives, it is sending. Check the wiring
Your code looks fine, although i'd add a DEFAULT for debugging...
Only thing I don't have is a common Gnd, but if send works receive should work too, no?
you need always a common ground even if you use full duplex lines.
bear in mind if you are using the same power source there is no need for a common ground.
I would say there is no reason not work...
"the devil is in the details"
Please provide more details:
I will play with common ground, and the line ending. Will see if that fixes the issue. Otherwise I feel that it is most likely what I'm sending the arduino uno. Might not be in the correct form.
Arduino Uno diagram: https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf
Uno has only one serial port: Pins 0 and 1 and is shared with another micro-controller (atmega16u2) to handle the USB communication.
When you connect to your arduino to monitor the communication the usb controller takes control over the serial port and if both pins are connected to the EZB you may have a problem.
You should use only the ARC serial monitor.
if you want to use the arduino usb/serial console or during arduino firmware uploads you need to disconnect any wires on pins 0 & 1, special the pin 0 (RX).
If you need more than one serial port, it helps the debug process:
Arduino Uno:
use SoftwareSerial library to implement a software serial port: https://www.arduino.cc/en/Reference/softwareSerial and use those pins to communicate with EZB, keep the hardware serial for firmware uploads and debug serial console
Or use another arduino:
Arduino Leonardo has 2, USB + 1
Arduino Mega has 4: USB + 3
Teensy 3.2 Cortex M4 (Supports Arduino Ide) has 3