2021-09-01
Announcements
-
Lab 1 tomorrow. Bring your LaunchPad and AD2
-
No class Friday
-
Can 1-2 people switch sections A-→ B ?
Class time
Nano blink
Start the Arduino IDE on your PC and first configure the Board:

Open the Blink example:

Verify/Compile the sketch.
Connect your Nano to your PC, if not already.
Upload to your board.
-
There may be a missing driver, hang tight.
Check that the LED is Blink-ing.
Modify the code so the LED blinks differently in some way (your choice). Re-upload and verify that it does what you expected it to do.
Arduino Nano clone schematic: https://easyeda.com/eeoj/arduino-nano-clone-ch340
-
^ after another, closer, look, this schematic likely has a couple small errors, so caveat lector
TOKEN OPPORTUNITY: Make your own copy of the EasyEDA schematic, find the mismatches against your Nano clone, document these findings, and share the fixed schematic.
NAN(D)O Gate
Objective: create a NAND gate using your Nano.
I/O ports
Microcontrollers typically group sets of pins and related hardware functions into ports and the ATmega328P
is no different.
These port names frequently are even embedded into the pin names.
Looking at the schematic:
-
How many ports does the uC have?
-
How many bits are part of each port?
-
What are the port names?
Observe how the chip pin names do not match the Arduino pin labels!
Skim this document: Arduino ref: Port Registers
Then modify your code:
-
Replace
pinMode(...)
withDDRB = 0b00100000;
-
Replace the
digitalWrite(...)
statements with ` PORTB = 0b00100000;` or another appropriate value
What is going on here? What do these binary numbers mean??
What things need to happen in order to implement a NAND gate using the pins attached to PORTB
?
How do you read the state of a pin without using digitalRead()
?
References
EasyEDA is a neat tool that does schematic + simulation + PCB design
-
DYK: Valpo licenses the full version of CircuitLab? Use your
@valpo.edu
email to register, then** find the "Activate Membership" button in your account settings.