9. Embedded Programming¶
This week: learning how to make a thing do a thing. Intro to: Inputs, Outputs, Sensors, Arduino, and Programming.
The Process & Reading a Datasheet¶
- Here is the Data sheet I reviewed for the ATTiny44. It was overall pretty impenetrable.
-
But I did find something recognizable that I could make sense of: the ATTiny44 Datasheet pinout diagram:
-
Here is a slightly more useful ATTiny 44 Pinout Diagram to determine the cooresponding Arduino pins (3 and 7):
Embedded Programming Demo by me on Vimeo.
Useful Links and Notes¶
- Microcontroller Architecture by CircuitBread
- Arduino Accelerometer Tutorial for the MPU6050
- Fab Acad Tutorial for ATTiny Using Arduino
- Arduino Notes: New Family of boards; add to Board Manager in Arduino
Code Example¶
Arduino Push Button LED Code:
// constants won't change. They're used here to set pin numbers:
const int buttonPin = 3; // the number of the pushbutton pin
const int ledPin = 7; // the number of the LED pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
Last update:
June 13, 2022