The Easy Module Shield V1 is a basic shield for the Arduino which has several useful components fitted that can be used for beginners learning, here is a list of these components
- A DHT11 temperature and humidity sensor
- An LM35 temperature sensor
- A piezo buzzer
- An RGB LED
- A blue LED and a red LED
- An IR receiver
- A photoresistor
- A rotary potentiometer
- Two pushbuttons
I wanted to see if these could be used with one of the Nucleo boards, the good news is that using the Mbed compiler I was able to use all of the devices on the board.
Lets look at some examples using this shield
Code
Flash the D12 LED
[codesyntax lang=”cpp”]
#include "mbed.h" DigitalOut myled(D12); int main() { while(1) { myled = 1; // LED is ON wait(0.2); // 200 ms myled = 0; // LED is OFF wait(1.0); // 1 sec } }
[/codesyntax]
RGB LED example
[codesyntax lang=”cpp”]
#include "mbed.h" DigitalOut redled(D9); DigitalOut greenled(D10); DigitalOut blueled(D11); int main() { while(1) { redled = 1; // LED is ON wait(0.2); // 200 ms redled = 0; // LED is OFF wait(1.0); // 1 sec greenled = 1; // LED is ON wait(0.2); // 200 ms greenled = 0; // LED is OFF wait(1.0); // 1 sec blueled = 1; // LED is ON wait(0.2); // 200 ms blueled = 0; // LED is OFF wait(1.0); // 1 sec } }
[/codesyntax]
Pot , LED and terminal output example
[codesyntax lang=”cpp”]
#include "mbed.h" Serial pc(USBTX, USBRX); AnalogIn analog_value(A0); DigitalOut led(LED1); int main() { float meas; pc.printf("\nPot example\n"); while(1) { meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0) meas = meas * 3300; // Change the value to be in the 0 to 3300 range pc.printf("measure = %.0f mV\n", meas); if (meas > 2000) { // If the value is greater than 2V then switch the LED on led = 1; } else { led = 0; } wait(0.2); // 200 ms } }
[/codesyntax]
LDR, LED and terminal out example
[codesyntax lang=”cpp”]
#include "mbed.h" Serial pc(USBTX, USBRX); AnalogIn analog_value(A1); DigitalOut led(D12); int main() { float meas; pc.printf("\nLDR example\n"); while(1) { meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0) meas = meas * 3300; // Change the value to be in the 0 to 3300 range pc.printf("measure = %.0f mV\n", meas); if (meas > 2000) { // If the value is greater than 2V then switch the LED on led = 1; } else { led = 0; } wait(0.2); // 200 ms } }
[/codesyntax]
So good news it can be used with a Nucleo
Links
Keyes V1 FR4 Multi-Purpose Shield Learning Module for Arduino – Red – $7.34
from: DealExtreme
ST NUCLEO-F401RE STM32F401RE Development Board for Arduino – White + Multicolored
from: DealExtreme