Menu

Gearmotor stops working when I add in IR remote

Arduino·jryan26·7 months ago
#qwhU0P5d
#reddit#include#motorspeed#analogwrite#value
Reading 0:00
15s threshold

Before I add in any of the IR Remote code, the nobby gearmotor speed scales with the potentiometer. When I add the IR remote control code the motor goes to 1 rpm unless the potentiometer is at max value.

#include <IRremote.h> #include <Servo.h> Servo steerServo; int recv_pin = 3; int trig= 13; int echo= 12; int motor1= 10; int motor2= 9; int pot= A5; int led= 2; int servo1= 5; int motorSpeed= 0; int maxSpeed= 255; float distance; float time; bool isMoving= false; void setup(){ Serial.begin(9600); steerServo.attach(servo1); IrReceiver.begin(recv_pin); pinMode(trig, OUTPUT); pinMode(echo, INPUT); pinMode(motor1, OUTPUT); pinMode(motor2, OUTPUT); pinMode(pot, INPUT); pinMode(led, OUTPUT); steerServo.write(90); } void loop() { maxSpeed = map(analogRead(pot), 0,1023,0,255); Serial.print("Max Speed"); Serial.println(maxSpeed); if (IrReceiver.decode()) { IrReceiver.resume(); int value = IrReceiver.decodedIRData.command; Serial.println(value); if(value == 16) { //1 pressed for forward steerServo.write(90);…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.