Communicating Between Arduino Esplora and Uno
by KNEXnCoding in Circuits > Arduino
2563 Views, 14 Favorites, 0 Comments
Communicating Between Arduino Esplora and Uno
Hello, in this short tutorial, I will demonstrate the process of controlling the Arduino Uno with the Arduino Esplora board.
For this project you will need:
- An Arduino Uno
- An Arduino Esplora
- 1 Jumper Cable
Assuming you have all this, let's get started!
Code for Esplora
In order for this to work, we need to send code to both the Uno, and the Esplora. Let's start with the Esplora code first. Copy and paste this to a blank sketch, make sure the Tool settings are appropriate, and upload the code to the Esplora.
#include <Esplora.h> // Esplora Library
int out = 14; // Output Pin
void setup() {
pinMode(out, OUTPUT); // set as output }
void loop() {
int button = Esplora.readButton(SWITCH_DOWN); // bottom button on esplora if (button == LOW) { // if button is pressed....
digitalWrite(out, HIGH); // send signal to pin }
else { // if not....
digitalWrite(out, LOW); don't send signal to pin } }
What this code does is send a signal to pin 14 on the Esplora, which will be connected to a pin on the Uno later.
Code for Uno
Now, make a new sketch, and copy and paste the following code. Make sure to set Tools > Board > Uno before you upload, and make sure it's uploading to the correct port.
int input = 3; // gives name to pin 3
void setup() {
pinMode(in, INPUT); // sets pin 3 as input pinMode(13, OUTPUT); // sets pin 13 as output }
void loop() {
int signal = digitalRead(input); // reads input
if (signal == HIGH) { // if there is a signal...
digitalWrite(13, HIGH); // turn LED on }
else { // if not...
digitalWrite(13, LOW); // turn it off
} }
What this code does is check for a signal coming into Pin 3. If there is a signal, the internal LED connected to Pin 13 on the Uno will turn on. However, in order to get a signal, we will need to connect the Uno and Esplora together.
Connect the Two
Now, for the easiest step of this whole project, connect Pin 3 on the Uno to pin 14 on the Esplora as shown in the photo above. If you did everything correctly, when you press the bottom button on the Esplora, the small LED on the Uno will turn on and off as you press the button!
Now that you can blink an LED, think about how you can apply this to other, perhaps more useful things. Hope this helped! Feel free to comment any questions or suggestions below!