Documentation Week 10

Assignment for week 10

Use an Output device

As an output device i decided to use a little speaker to create vibrating sounds.

I used the same board as in the last assignment with the Input device. After connecteing the speaker i wrote the following code that plays the tone.

int i = 0; //int for analog value

bool up = true; //bool as switch

void setup() {

pinMode(A3, OUTPUT); //speaker pin as output


void loop() {


i++; //raise the value


i--; //lower the value


if(i >= 255){

up = false; //flip switch if value is too high


if(i <=0){

up = true; //flip switch if value is too low


analogWrite(A3, i); //write value to speaker pin