NSWI170 Computer Systems

Arduino

The first order of business is to get your own Arduino within the first two weeks! You can either buy it or borrow it from the library at Mala Strana (only there!). If you are going to the library for the first time it might be a good idea to register first to speed up the process. There is an online registration form you may use.

The Arduino you borrowed is equipped with a FunShield which provides a decent user interface (buttons, LEDs, and 7seg display). To use it, you will require a Funshield.zip library. It needs to be installed once (which we will do step by step in the labs) into Arduino IDE, then you can use it as a C++ header.

ReCodEx submissions

Your solutions should be submitted to ReCodEx for validation and archiving. Please, always submit only solution.ino file unless specified otherwise. The teachers will use ReCodEx to give you feedback via code reviews.

ReCodEx uses a Moccarduino emulator to test your solution. It emulates the Arduino API on a functional level and provides helpers to write testing scenarios that use the FunShiled. There are certain limitations and differences from the actual Arduino hardware, please read the associated README. Furthermore:

Focus also on the quality of your code and check out the coding guidelines.

Header file funshield.h

Defines important constants that you will require when working with FunShield. Do not submit this file in ReCodEx (it is automatically included).

#ifndef FUNSHIELD_CONSTANTS_H__
#define FUNSHIELD_CONSTANTS_H__

// convenience constants for switching on/off
constexpr int ON = LOW;
constexpr int OFF = HIGH;

// 7-segs
constexpr int latch_pin = 4;
constexpr int clock_pin = 7;
constexpr int data_pin = 8;

// buzzer
constexpr int beep_pin = 3;

// LEDs
constexpr int led1_pin = 13;
constexpr int led2_pin = 12;
constexpr int led3_pin = 11;
constexpr int led4_pin = 10;

// buttons
constexpr int button1_pin = A1;
constexpr int button2_pin = A2;
constexpr int button3_pin = A3;

// trimmer
constexpr int trimmer_pin = A0;

// numerical digits for 7-segs
constexpr int digits[10] = { 0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90 };
constexpr int empty_glyph = 0xff;

#endif