Click here to Skip to main content
15,887,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello every one .
I want to blink three different Led with master and slave avr eith spi protocol
I have interfaced the two avr with spi protocol the problem is when i press one of the three push buttons the three leds blinks. Because the receive condition is the same for the three leds . So i want to make the 2nd avr knows that which button i have pressed in the first avr.

What I have tried:

I have interfaced the two avr with spi protocol the problem is when i press one of the three push buttons the three leds blinks. Because the receive condition is the same for the three leds . So i want to make the 2nd avr knows that which button i have pressed in the first avr.
Posted
Updated 26-Apr-18 0:25am

1 solution

This is rather unclear without knowing what you have done so far.

But all you have to do is sending data that indicates which button has been pressed. This requires the definition of a "protocol" that defines the meaning of the data transferred via SPI.
 
Share this answer
 
Comments
Member 13799356 26-Apr-18 6:55am    
First of all thanks for your response, secondHow to send data that indicates which button i have pressed??
Jochen Arndt 26-Apr-18 7:11am    
You have to define a protocol.
You can for example send a byte where the lowest bit is set when button 1 is pressed, the next when button 2 is pressed and so on.
Member 13799356 26-Apr-18 8:00am    
can you please show me code example for this
Jochen Arndt 26-Apr-18 8:08am    
I can't really because you have not shown any code you have written so far or even told us which programming language you are using.

A pseudo code C like example:
char data = 0;
if (isButton1Pressed)
data |= 1;
if (isButton2Pressed)
data |= 2;
if (isButton3Pressed)
data |= 4;
/* Now send data */

At the receiving side check which bit is set and act accordingly (e.g. switch the corresponding LED on or off).
Member 13799356 26-Apr-18 8:42am    
Thank you !

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900