* Deconvolving Arduino Process Here it is!!!!!! https://arduino.github.io/arduino-cli/latest/getting-started/ follow this and all things become clear please try this on the student VM https://arduino.github.io/arduino-cli/sketch-build-process/ https://arduino.github.io/arduino-cli/platform-specification/ https://arduino.github.io/arduino-cli/latest/installation/ curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/local/bin sh * SAM D21 SPI https://microchipdeveloper.com/32arm:samd21-sercom-spi-master-configuration https://github.com/ostaquet/Arduino-Nano-33-IoT-Ultimate-Guide https://microchipdeveloper.com/32arm:samd21-code-gcc-sercom-spi-master-example https://microchipdeveloper.com/local--files/32arm:samd21-code-gcc-sercom-spi-master-example/32arm-samd21-gcc-sercom-spi-master-demo.zip https://learn.adafruit.com/using-atsamd21-sercom-to-add-more-spi-i2c-serial-ports/creating-a-new-spi * SPI Master Mode // SCK = PINB5 = Digital 13 (Output) // MISO = PINB4 = Digital 12 (Input) // MOSI = PINB3 = Digital 11 (Output) // CS = PINB2 = Digital 10 (Output) #define SPI_DDR DDRB #define CS PINB2 #define MOSI PINB3 #define MISO PINB4 #define SCK PINB5 void SPI_init() { // set CS, MOSI and SCK to output SPI_DDR |= (1 << CS) | (1 << MOSI) | (1 << SCK); // enable SPI, set as master, set SPI_Mode=3, and clock to fosc/128 SPCR = (1 << SPE) | (1 << MSTR) | (1 << CPOL) | (1 << CPHA) | (1 << SPR1) | (1 << SPR0); } uint8_t SPI_send(uint8_t data) { // load data into register SPDR = data; // Wait for transmission complete while(!(SPSR & (1 << SPIF))); // return Data Register return SPDR; } * Arduino Reference https://gammon.com.au/forum/bbshowpost.php?bbtopic_id=123 https://howtomechatronics.com/tutorials/arduino/arduino-wireless-communication-nrf24l01-tutorial/ * *********************************************************************************************** * Serial Ports - NodeCMU ESP12F 8266 * *********************************************************************************************** https://github.com/esp8266/Arduino/blob/master/doc/reference.rst#serial The serial ports are very easy to use Serial.begin(9600); Serial.swap(); Normally the serial port is GPIO1 - TX GPIO3 - RX The Serial.swap() function moves it to GPIO15 - D8 - TX GPIO13 - D7 - RX The problem with using GPIO3 as RX is that you have to disconnect it during flashing. This is like the Arduino. Note that when you swap it however, you can no longer use the Arduino IDE serial port monitor. When you do use the serial port monitor, not that the TX signal goes both to the pin and the serial port monitor. The RX signal could come from either the monitor (USB) or the RX pin. I believe the monitor is higher impedance, to the RX pin dominates if connected, but in any case this is probably another reason to switch to the GPIO13 (D7) as the RX pin with the Serial.swap() To read the serial port while (Serial.available() > 0) { ch = Serial.read(); . . . } To print, use Serial.println("Hello World") * *********************************************************************************************** * Simple Example Program for ESP8266 // * *************************************************************************** #include #include #include #include #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels #define OLED_RESET -1 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); void setup() { Serial.begin(9600); Serial.println("Enter display.begin"); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); Serial.println("Leave display.begin"); display.clearDisplay(); display.setTextSize(1); display.setTextColor(SSD1306_WHITE); display.setCursor(0,0); display.println("Hello World!"); display.println(""); display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); display.println("3.141592"); display.println(""); display.setTextSize(2); display.setTextColor(SSD1306_WHITE); display.print("Hello "); display.println("Jack"); display.display(); delay(2000); display.clearDisplay(); display.drawRect(0, 0, display.width(), display.height(), SSD1306_WHITE); display.display(); } void loop() { static int ival = 0; char jstr[32]; display.setTextColor(SSD1306_WHITE, SSD1306_BLACK); display.setCursor(5,12); sprintf(jstr, "I = %3d", ival); display.println(jstr); display.setCursor(5,36); sprintf(jstr, "J = %3d", ival*3); display.println(jstr); display.display(); ival = ival + 1; if (ival >= 100) { ival = 0; } delay(1000); } // * *************************************************************************** * Maker Focus SSD1306 Displays I bought four of these from Amazon They are 128x64 There is some confusion as to the I2C address. As pointed out in an Amazon Review, on the board itself it lists 0x78 but the correct address is 0x3C. You can install the Adafruit SSD1306 Library and Adafruit GFX Libraries from the Arduino IDE library manager For some reason, the I2C addresses in the examples show 0x3C for a 128x32 display, and 0x3D for a 128x64 display These are 128x64 displays, but the correct address is 0x3C. I found this by trial and error, but then found that the Amazon reviewer noted that 0x3C is correct too. On the Arduino Uno, you connect the SDA-->A4, SCL-->A5 On the ESP8266, you connect the SDA-->GPIO4=D2, SCL-->GPIO5=D1 It is very important to set : OLED_RESET = -1 if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C) To get started, you can load up the ssd1306_128x64_i2c example sketch Change I2C address 0x3D to 0x3C Change OLED_RESET from 4 to -1 * Wifi with screen https://www.youtube.com/watch?v=QVOMVSsF1aE * You really need to download the arduino ide all the code for libraries is in : /cygdrive/c/Program Files (x86)/Arduino/hardware/arduino/avr/libraries/SPI/examples/BarometricPressureSensor cd /cygdrive/c/Program\ Files\ \(x86\)/Arduino/hardware/arduino/ * *************************************************** sudo yum install avr-gcc.x86_64 avrdude.x86_64 sudo yum install avr-libc.noarch ll /dev/tty* > junk1.txt (plug in arduino) ll /dev/tty* > junk2.txt diff junk1.txt junk2.txt vim MakeFile good totorial ( https://bytes.usc.edu/files/ee109/labs/lab1v/EE109Lab1.pdf ) * **************************************** DEVICE = atmega328p CLOCK = 16000000 PROGRAMMER = -c arduino -b 115200 -P /dev/ttyACM0 OBJECTS = gregArdo.o lcdFast.o FUSES = -U hfuse:w:0xde:m -U lfuse:w:0xff:m -U efuse:w:0x05:m # Tune the lines below only if you know what you are doing: AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)