Arduino Code Not Executing Command

I’m using this Arduino code (modified to have the LED on the LEFT_PWM) to try and control an LED. Using this code, the LED is in a perpetual ON state. Here is an example serial out from the Arduino:

Saving LED Setpoints
Echoing New LED Command
Waiting for OK to execute...
Reading Vial:6
String Completed, stop averaging
Command Executed!

It seems that the off command is executed just fine, but to no effect. I am able to change the set values via the server_test.py script, also with no effect.

Saving LED Setpoints
Echoing New LED Command
Waiting for OK to execute...
Reading Vial:13
String Completed, stop averaging
Command Executed!

Other Arduino scripts work as expected. This test script (also modified to go to the LEFT_PWM) turns the LED off and on at one second intervals, so we can rule out a hardware malfunction.

The stir script also works as expected (turns the LED on and off at quick intervals). Commands can be sent to the stir script to turn it off entirely, which then turns the LED off. I also modified the stir script to have the address “light”, which allowed it to be controlled via “light” commands.

Really don’t know enough about the Arduino Code that I’m using to control LED to understand what’s going wrong, though I did try messing around with it.

Any help much appreciated!! Thanks.

Do you mean RIGHT_PWM? Can you confirm that the PWM board is fully pressed down into the motherboard? I’ve had problems before where the boards aren’t completely connected and pumps/lights don’t actuate. The black plastic on the samd21 header pins and the motherboard connector should be touching with no gap.

I mean LEFT_PWM controls the LED because it’s on pin 7.

I pressed everything down just to make sure and got the same result.

I don’t think it’s a hardware issue because other Arduino scripts work as expected and the LED actuates

Sorry I guess I’m a little confused here. So you’re trying to control pin 7 (or address 3) on the LEFT_PWM board, correct? There is also pin 7 (address 3) for the RIGHT_PWM. If you’re trying to actuate LEDs on the left pwm board, the code for OD should just work for you, as that is what is being actuated by the od_led address.

Can you share the exact server test script you are using? If I understand what you did up there, you tried to send a value of 3000 to the arduino, but nothing happened? You should try changing between 0 and 4095.

I think the confusion is that when I said pin 7 I probably should have said the PWM board in slot 7. I was referring to pin 7 on all of the Vial Boards, which is controlled by the PWM in slot 7 on the motherboard.

This is the server test script I’m using. An example usage for it: python light_test.py light 0

It’s sending a command to the server:

I don’t know what the difference is between the od_led code and the code I was attempting to use, but the od_led code works! Just had to change the parts that said od_led to light for my purposes.

Thank you so much!

1 Like

I am currently attempting to send light commands in serial. I adapted the code from the od_led, with appropriate changes in the mux shield registers and SIG_PIN, changing LEFT_PWM to RIGHT_PWM, and attempted “light” and “blue_led” as addresses. I can get the RIGHT_PWM to blink the LEDs or cycle between values by uploading Arduino code but still cannot seem to get it to register serial commands. Am I missing something?

Are you sending the serial commands via the USB (e.g. Arduino IDE) or are you trying to do it via the Serial1 line (RS485 via the RPi)?

Either way I would recommend testing it via the Arduino IDE first, before hooking it up to the eVOLVER RS485 line. If you are having trouble with the Serial USB commands, it probably is that the code defaults to reading the Serial1 line instead of the USB. For example, the lines to change the code are here for the STIR Arduino code but should be found for all Arduino level code that is communicating via serial commands.

So to change it to read USB commands, update the serialEvent() function to the following:

void serialEvent(int time_wait) {
  for (int n=0; n<time_wait; n++) {
      while (SerialUSB.available()) {
        char inChar = (char)SerialUSB.read();
        inputString += inChar;
        if (inChar == '!') {
          stringComplete = true;

Hope this helps!