Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello I need help with my Arduino code and to figure out why it is not working, Keep in mind please that I am not

Hello I need help with my Arduino code and to figure out why it is not working, Keep in mind please that I am not allowed to use the library "SoftwareSerial".

Using two Arduinos, a servo motor, and a Bluetooth module a team of two students must design a wireless antenna controller. The system will work with a smartphone device sending data though Bluetooth. This data will be received by the Bluetooth module and transmitted to the master Arduino via UART with a baud rate of 9600 bps. Once the master Arduino receives the data in string format, it must convert it to an integer and transmit it to the slave Arduino via I2C. The slave Arduino will then use this integer to replace the servo motor in the desired degrees elevation. Keep in mind that the elevation will only be able to go from 0 to 180 degrees, so the string that is expected to be received from the smartphone device must be in this same range. For the I2C address use 0x03.

This is the codes I have started but they are not working

image text in transcribed

image text in transcribed

Lab_4_code | Arduino 1.8.20 Hourly Build 2021/12/20 07:34 Lab_4_code \#include \#define Slave1 0x03 int rx=0 void setup() \{ // put your setup code here, to run once: Serial.begin(9600); //Initialize UART, baud rate is 9600 bps Wire.begin(); \}} void loop() \{ // put your main code here, to run repeatedly: if (Serial.available()) \{ String stringNumber = Serial.readStringUntil (\ ' );// read data from Bluetooth module rr= stringNumber.toInt ();// convert string to integer Wire.beginTransmission(Slave1); // start I2C transmission to slave Arduino Wire.write(rx); // write integer value to slave Arduino Wire.endTransmission(); // end I2C transmission \} \} Lab_4_code_slave | Arduino 1.8.20 Hourly Build 2021/12/20 07:34 Save Lab_4_code_slave \#include \#include \#define ADRESS 003 Servo sg90; int pos =0 char rx ; String msg; void setup() \{ //Initialize I2C Wire.begin(ADRESS); Wire. onReceive(receiveEvent); sg90.attach(9) \} void loop() \{ \} void receiveEvent(int bytes) \{ int rx= Wire. read() pos =map(rx,0,180,0,180); sg90.write(pos); \}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions

Question

what is a peer Group? Importance?

Answered: 1 week ago