Jump to content
Electronics-Lab.com Community

Use Python to talk to another Microcontroller via SPI

Recommended Posts

SPI is a highly important peripheral for microcontroller as it allows for high speed communication over short range, here is how we use python to send msg to another microcontroller over SPI



  • Ameba x 1, Arduino UNO x 1



在通讯连接建立之前,需要先将以下代码烧录到Arduino UNO。

rtc = RTC()
// SPI Master Write //
void setup (void) {
Serial.begin(115200); //set baud rate to 115200 for usart
digitalWrite(SS, HIGH); // disable Slave Select
SPI.begin ();
void loop (void) {
char c;
digitalWrite(SS, LOW); // enable Slave Select
// send test string
for (const char * p = "Hello, world!\r" ; c = *p; p++) {
digitalWrite(SS, HIGH); // disable Slave Select

Arduino UNO将以如下图所示的连接方式和Ameba连接,我们使用第“0”组SPI作为从机, 并将Arduino UNO当作SPI的主机。



from machine import SPI
s1= SPI(0 , mode = SPI.SLAVE)
for i in range(14):
Link to comment
Share on other sites

  • MENG XI changed the title to Use Python to talk to another Microcontroller via SPI

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.