![]() Wire.onReceive(receiveEvent) // Call receiveEvent when data is received Wire.begin(0x8) // Initialize the I2C communication as a slave with address 0x8 Volatile bool i2cDataReceived = false // Flag to indicate if I2C data has been receivedĪFMS.begin() // Initialize the Motor Shield Volatile uint8_t command = 0 // Received command variable This is my test-code so far, the motor functions will be replaced with the function that takes X and Y as input of course:Īdafruit_MotorShield AFMS = Adafruit_MotorShield(0圆0) // Create Motor Shield object with I2C address 0圆0Īdafruit_DCMotor *motor1 = AFMS.getMotor(1) // Motor 1Īdafruit_DCMotor *motor2 = AFMS.getMotor(2) // Motor 2Īdafruit_DCMotor *motor3 = AFMS.getMotor(3) // Motor 3Īdafruit_DCMotor *motor4 = AFMS.getMotor(4) // Motor 4 How can I send two values and know which one is sent? Like so far I got a simple code working that turns my motors on and Off when I send a 1 or a 0 using There's gonna be 4 of those (one for each motor) and the robots orientation from a gyroscope.įor now I'm mainly interested in receiving values on the Arduino and controlling the motors. ![]() The Arduino is going to send back sensor to the Pi, these might go above 255, as they contain motor rpm, I'll probably use a uint16_t for that. The Pi is going to send values to the Arduino, mostly 8 bit ints I believe (values between 0 and 255, might change at some point but for now that's enough.) These are command values for the Arduino. I'm in the process of developing a robot using ROS2 on a Raspberry Pi that communicates with an Arduino Uno using I2C.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |