# Embedded programming

For this week assignment we had to :

• Link to the group assignment page
• Documented what you learned reading a microcontroller datasheet
• Described the programming process you used
• Included a short ‘hero video’ of your board

This week we had to study a microcontroller datasheet… Surprisingly I read a bit the documentation about the ATTiny 412, I used the chip pinout to remind the wiring of everything.

On my last board I forgot to wire the button to the microcontroller.... I had to mill an new board fixing that.

I had a lot of trouble programming my new board even if the first board was pretty easy to program… Indeed, I soldered a wrong board… Attiny85 instead of 412 (They mixed in my zip bag !)

After changing to the right board, I soldered everything, and it blinked ! Here is the workflow I used :

# Using Arduino and PyUPDI

I first used megaTinycore from SpaceConde on GitHub. I used his board package to program my board using Arduino IDE. To install megaTinycore you have to add a new entry in the Arduino settings.

At that time I didn’t figure out why my board wasn’t working properly, so I tried to program an ATtiny85 as a Attiny 412… Anyway, As PyUpdi wasn’t working, I wired an Arduino nano to test the JTAG programming methods

It didn’t work … As expected. I then tried to figure out what was going on using a multimeter to check the continuity of my board

I figure out the microcontroller was wrong just here at 2am ! :D I then came back to PyUPDI with a working board

To program the board, you have to install megaTinyCore, then you’ll have access to the Attiny412 board in the board list. I didn’t change the settings, but I explore everything setting while searching how to program my wrong chip…

#define PIN_BUTTON 0
#define PIN_LED 1

#include <SoftwareSerial.h>

SoftwareSerial mySerial(3, 2); // RX, TX

void setup() {
Serial.begin(115200);

pinMode(PIN_LED, OUTPUT);
pinMode(PIN_BUTTON, INPUT);

delay(1000);

}

void loop() {

mySerial.println("Button pressed !");
digitalWrite(PIN_LED, HIGH);
}else{
mySerial.println("Nothing happennig...");
digitalWrite(PIN_LED, LOW);
}

if(Serial.available()){
}
delay(200);

}


Unfortunately that code didn’t Code… But this one does ! I need to figure out why =)

#include <SoftwareSerial.h>

#define LED_PIN 1
#define BUTTON_PIN 0

#define RX_PIN 3
#define TX_PIN 2

SoftwareSerial softSerial(RX_PIN, TX_PIN);

void setup() {
softSerial.begin(115200);
while(!softSerial);

pinMode(LED_PIN, OUTPUT);
pinMode(BUTTON_PIN, INPUT);
}

void loop() {
softSerial.println("Hello !");

}


And It worked !

Last update: June 28, 2022