This question please help me.

This question please help me.

Search for bit bang SPI.
I finished the last of my homework over 50 years ago. I will not do yours. I will help if I can, though.
Monitor the ss line and when it goes from high to low watch the clock line. Once the clock goes from low to high wait 1/2 bit time and sample the mosi (data from master) line. Then wait 1 bit time and sample mosi. do that 6 more times for a total of 8 bits read. You could use the bitWrite function to write the bits to a byte to print out.
You help, but I don't fully understand. I wish you wrote the code. Can you tell me what I need to add to the code in a little simpler language?
Do a google search for "arduino bit bang SPI tutorial". I get 337,000 hits. Do some reading. Try to write the code.
I found it too. but nothing related to spi communication. I found a site and sent it to you. There is a master code but no slave code. Post the link you found?
@aqwequery your assignment/homework has several parts:
You need to research what SPI is and what the 4 signals are.
You should read up on how an SPI master device transfers data to a slave device.
Then you can write some code yourself.
That should give you an idea of how YOU are going to solve the problem. The previous link should give you enough detail. If not, google is your friend.
HINT: You will get much more help from the forum if you have a go yourself first. Post YOUR code for the master and slave boards.
You will also learn more by doing it yourself rather than cutting and pasting code you found on the internet.
Please do not post screen shots of code. It can not be copied to the IDE or a text editor for examination or testing. Read the forum guidelines to see how to properly post code and information on how to get the most from this forum.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
Put comments in the code so that we can tell what you are trying to do.
When is the assignment due?
(post deleted by author)
I can't write that code overnight. I have written the synchronous serial communication code (bit bang) in Z80 and 8051 assembly but it would take me some time to write it in C++ for Arduino.
can you write the code in the photo in the picture above i send
Seriously! Can you not type it in yourself?
you just talk. do. let's see?
hahahahah you didn't like i guess
You go like this:
1. Connect Master Arduino and Slave Arduino as per following diagram (Fig-1).

Figure-1:
2. Convert the following timing diagram (Fig-2) into codes:

Figure-2:
3. Upload the following sketch in Master Arduino.
byte dataOut = 0b10110101;
void setup()
{
Serial.begin(9600);
pinMode(2, OUTPUT); //IRQ
digitalWrite(2, HIGH);
pinMode(4, OUTPUT); //DataOut line = MOSI
pinMode(5, OUTPUT); //Clock line (SCK)
digitalWrite(5, LOW);
}
void loop()
{
digitalWrite(2, LOW); //interrupt
delayMicroseconds(20);
digitalWrite(2, HIGH);
for (int i = 7; i >= 0; i--)
{
digitalWrite(4, bitRead(dataOut, i));
//-----
digitalWrite(5, HIGH);
delayMicroseconds(500);
digitalWrite(5, LOW);
delayMicroseconds(500);
}
delay(2000); //test interval
}
3. Upload the following sketch in Slave Arduino.
byte recData;
volatile bool flag = false;
void setup()
{
Serial.begin(9600);
pinMode(2, INPUT_PULLUP); //INT0
pinMode(4, OUTPUT); //DataIn line = MOSI
pinMode(5, INPUT); //Clock line (SCK)
attachInterrupt(digitalPinToInterrupt(2), ISRZ, FALLING);
while (digitalRead(5) != HIGH)
{
;
}
}
void loop()
{
if (flag == true)
{
for (int j = 7; j >= 0; j--)
{
while (digitalRead(5) != HIGH)
{
;
}
bitWrite(recData, j, digitalRead(4));
delayMicroseconds(500);
}
Serial.println(recData, BIN);
flag = false;
}
}
void ISRZ()
{
flag = true;
}
4. Output (anyway not stable)
10110101
10110101
Thank you very much, you are the best. How can I print the string I want to the output screen?
Maybe you should figure that out for yourself?
Your laziness has already paid off in that you got someone else to write the code for you. Good luck with that approach on your first job out of school.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.