Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello I am creating a a wireless light dimmer using two arduinos with shields and xbee trancievers. The arduino i would like to focus in

Hello I am creating a a wireless light dimmer using two arduinos with shields and xbee trancievers. The arduino i would like to focus in this question will have sparkfun IR remote and Kirda Ac light dimmer module connected to it. I need help completing a sketch that will be uploaded to the Arduino Uno. The arduino will have three cases. The first case is connected to button_a, it needs to read values from serial communiction and dim the light bulb accordingly( the values will come from the first arduino using a photocell ). The next case is button_b, it will make the light bulb at max brightness giving the user the ability to turn up or down the brightness using button_up & button_down. The last case is the button_c, which is the light bulb at min brightness giving the user the ability to turn up or down the brightness using button_up & button_down.

Can you please complete the sketch for me.

code so far

#include #include #define NUM_BUTTONS 9

const uint16_t BUTTON_POWER = 0xD827; // i.e. 0x10EFD827 const uint16_t BUTTON_A = 0xF807; const uint16_t BUTTON_B = 0x7887; const uint16_t BUTTON_C = 0x58A7; const uint16_t BUTTON_UP = 0xA05F; const uint16_t BUTTON_DOWN = 0x00FF; const uint16_t BUTTON_LEFT = 0x10EF; const uint16_t BUTTON_RIGHT = 0x807F; const uint16_t BUTTON_CIRCLE = 0x20DF;

int AC_pin = 7 int receiver = 13; IRrecv irrecv(receiver); decode_results results; uint16_t lastCode = 0; int dim2 = 0; int dim = 128; int pas = 10; int freqStep = 65; char incomingByte; void setup() { Serial.begin(9600); // Use serial to debug. irrecv.enableIRIn(); // Start the receiver pinMode(AC_pin, OUTPUT); attachInterrupt(0, zero_cross_detect, RISING); Timer1.initialize(freqStep); Timer1.attachInterrupt(dim_check, freqStep);

} void zero_cross_detect() { zero_cross = true; i=0; digitalWrite(AC_pin, LOW); }

void dim_check() { if(zero_cross == true) { if(i>=dim) { digitalWrite(AC_pin, HIGH); i=0; zero_cross=false; } else { i++; } } } void translateIR() { switch(results.value) {

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

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

Students also viewed these Databases questions

Question

When is revenue recognized with respect to licenses?

Answered: 1 week ago

Question

A nucleus unit becoming critical means

Answered: 1 week ago

Question

Define Conventional Marketing.

Answered: 1 week ago

Question

Define Synchro Marketing.

Answered: 1 week ago

Question

Define marketing concepts.

Answered: 1 week ago

Question

1 what does yellow colour on the map represent?

Answered: 1 week ago

Question

=+ How well do you think you could do your job?

Answered: 1 week ago