Tutorial 1 and Step 6 on Basic Output for Intel® Galileo Boards

Documentation

Install & Setup

000006609

08/07/2019

Seeing Sound with an LED
In the Basic Input section of this lesson, step 4 describes how to connect the microphone sensor. Using the same circuit, we will expand on it by using an LED.

Step 1: Set up power for the LED
Connect the cathode (short leg) of the LED to the negative (blue vertical strip).
Connect the anode (long leg) of the LED to a section of the middle of the breadboard.

Step 2: Add a resistor
Using the same row as that the anode is connected, connect one side of the resistor.
Using the other half of the breadboard, connect the other end of the resistor in the same row.

Step 3: Connect to pin 9
Connect a wire from the row where the resistor is to pin 9. When this pin is sent a HIGH signal, it will go through the resistor, to the anode, light up the LED, then go to the GND.

Journey of the electric current

Here we see the journey of electrical current.

Once you have everything connected properly, run the following sketch:

// Using 'const' we ensure that pin_sound cannot be changed in this sketch
const int pin_sound = A0;
const int led = 9;
int sound_sample;

void setup() {
Serial.begin(57600);
// Set the digital pin 9, the LED, to behave as an output.
pinMode(led, OUTPUT);
}

void loop() {
sound_sample = analogRead(pin_sound);
// Using an if condition, we test to see if the sample is over 100.
if(sound_sample > 100){
// If the sample is over 100, send a high signal to the LED, turning it on
digitalWrite(led, HIGH);
}
else {
// If not, send a LOW signal, turning off the LED
digitalWrite(led, LOW);
}
// Print the sound sample to the serial monitor
Serial.println(sound_sample);
}

Once a sound sample over 100 is read, the LED is sent a HIGH signal, turning it on.

LED on