-
Notifications
You must be signed in to change notification settings - Fork 0
6 Programming
Ryan Britton edited this page May 21, 2019
·
4 revisions
- Open up Arduino IDE on one of the lab computers.
- Go to File > Preferences.
- Copy and paste the following URL into the Additional Board Manager URLs box:
https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json
- Click OK and go to Tools > Board: ... > Board Manager...
- Search for
SparkFun AVR Boardsand click Install. - Click Close and go back to Tools > Board: ... and scroll down until you find
SparkFun Pro Micro. - Go to Tools > Processor:... and select
ATmega32U4 (5V, 16 MHz). - Next go to Sketch > Include Library > Manage Libraries...
- Search for
keyboardand installHID by Arduino,Keyboard by Arduino, andMouse by Arduino. - Download the sample programs: https://github.com/rpbritton/keyboard-sail/archive/master.zip.
- Add your includes.
- Create your global variables.
-
setup()runs once at the beginning to configure stuff like your GPIO pins. -
loop()is called aftersetup()and then everytime it ends (like awhile (true)loop).
- Open
blinky.ino. Read through the comments to get a feel of what is going on. - Click Verify to check if the code compiles.
- If that works, click Upload. The controller LEDs should flash a few times and then one of them should start blinking at an interval.
- Open
basic-keyboard.inoin Arduino IDE and read through the code and comments. Try to understand what's going on. - Change the
rowPins[]array to be equal to your selected row pins starting from the top row and moving down. The syntax isrowPins[] = {Pin Number 1, Pin Number 2, Pin Number 3, ...};. For example:rowPins[] = {6, 3, 8, 4, 9, 7, 12};. - Do the same thing for the
colPins[]array, starting from the left column to the right column pins. - Next look at the
layout[numRows][numCols]2-dimensional array. For each row create another array with{},, with create one char for each column. For example:{'q', 'w', 'e', 'r', 't', 'y'},. For the codes of modifiers look at https://www.arduino.cc/en/Reference/KeyboardModifiers.