3

In order to make the ultrasonic sensor work, the Arduino has to run some code to control it. So it won't do anything while the Arduino is asleep. What you can do is have the Arduino sleep for some reasonable amount of time, wake up and read the sensor, and then go back to sleep. Maybe wake it up once every few seconds. Do you really need to react to a ...


3

Don't use Delay. CrossRoads provided a decent starting point for your code, but his code is based on delay(), which is a dead end. Instead of delay, use a bool running to track whether you're relay sequence is running or not. Also have an unsigned long startTime, and an array of bools to track if each relay is on or off. If !running, check the button. If ...


3

As noted by markshancock, you are using an older version of the Adrafruit Motor Shield library meant for the version 1 of the board (you have the version 2.3), and according to their forum they are not compatible (they use different communication protocols) use the newer version of the library https://forums.adafruit.com/viewtopic.php?f=31&p=276888


2

The commands you are using don't match the ones listed for this board. Here is the AF Documentation for the Motor Shield Board V2. Try #include <Wire.h> #include <Adafruit_MotorShield.h> #include "utility/Adafruit_MS_PWMServoDriver.h" Adafruit_MotorShield AFMS = Adafruit_MotorShield(); Adafruit_DCMotor *motor = AFMS.getMotor(2); void setup()...


2

The Tutorial.pdf document that describes the components in the kit does not tell you what the current draw of the motor is. Chapter 10 has 2 tutorials on how to use the motor with a relay or L293D IC. This suggests to me that the motor draws a lot more current than a digital output can provide. The tutorial using the L293D gives you the ability to vary the ...


2

There are two solutions that come to my mind, one more HW based and another more SW based. Solution 1 The HW way is to let the programmer control the LCD through 2:1 multiplexer(s). You will need to connect the LCD pins to the common pin of the multiplexer, the Programmer's ones to one of the two inputs and the Worker's to the other. Then the programmer ...


2

Your board will only present a serial port if the sketch that is running on it is programmed to present a serial port. The board does not have an actual serial port for communication with the PC - only what the sketch provides. If the sketch doesn't provide one, or if the sketch isn't running (for example if it was compiled for the wrong board by accident) ...


2

You'd use %% to get a single % as output. From the source code: double percent sign encountered, this is single percent sign escaped.


2

From your use of the number 360 at the end of the Encoders() function, I am thinking that you are using degrees for the angles. That won't work with sin and cos. The trig functions all expect angles in radians. To convert degrees to radians, multiply by PI/180.


1

You cannot call methods outside of a function. Move lcd.createChar(0, character); into setup.


1

It's better to avoid dynamic memory allocation on an Arduino, with only 2 KB of SRAM memory. Note that your arrays cost 2 (bytes/int) * (8 + 8 + 16) = 64 bytes. And it seems you are only storing booleans, which could be stored in one bit. So consider another alternative (I will not work that out, since maybe memory consumption is not a problem). However, ...


1

In your approach a button press will be detected every 100ms when you just keep the button pressed. So you have to set a flag when the button is pressed. When the button is not pressed while your flag is set, that's the event you're looking for. In this way you can detect both a button press and a release respectively. As @JRobert mentioned, there still has ...


1

A new chip cannot be programmed in that manner until it has the Bootloader installed. The Bootloader starts after a reset and monitors the serial interface to see if something is attempting to download code via the serial port. Selecting a Programmer has no effect on serial download, that only comes into play when Programming via the SPI pins SCK/MOSI/MISO/...


1

You're confusing readlines() with readline(). The former returns an array of lines, the latter a single line. You need to drop the [0] since you're not working with an array of lines, and you need to include the line endings that the Arduino sends: while True: message = ser.readline() print(message.decode('utf-8')) if message == 'MOVEMENT\r\n' ...


1

The digital/analog pins cannot directly source enough current to run a motor. Use the pin to control a switching device like a mosfet which then controls current flow to the motor.


1

I'm no expert, but I imagine something along these lines would work: char* day(int day) { static char* dayName[7] = {"Sunday", "Monday", .... }; if (day > 0 && day < 8) { return dayName[day-1]; } else return "Undefined"; } } In any case, I'll be interested to hear why it's wrong (-:


Only top voted, non community-wiki answers of a minimum length are eligible