Maple Lesson 10 - Light indicator"

From Microduino Wiki
Revision as of 13:20, 24 August 2014 by Jasonsheng (talk) (Created page with "{| style="width: 800px;" |- | ==Objective== In photoresistance experiment, the light is divided into two levels, strong or weak. This experiment will finish a light indictor u...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


In photoresistance experiment, the light is divided into two levels, strong or weak. This experiment will finish a light indictor using 4 LEDs and divides the light into 5 levels. Photoresistance receives the lighter, and light up more LED to achieve the purpose of instruction.


Microduino-CoreSTM32 is an ARM development board using STM32F103CBT6 chip. It use special Upin7 interface, the size is similar with a coin and fully compatible other Microduino modules.

  • Other hardware equipment
    • Breadboard Jumper one box
    • Breadboard one piece
    • Photoresistance one
    • LED Light-emitting diodes four
    • 220Ω four
    • 10k resistor one
    • USB Data cable one


The photoresistance's connection in contrast to the last time, the purpose is let you know the usage of photoresistance deeply. photoresistance directly connects to the power supply at one end, the other end through a resistance to connect GND . The initial state is low and with the increase of light intensity voltage is higher and higher.


const int analogInPin = 14;
const int ledPin = 4;

float sensorValue = 0;        // value read from the pot

int xl=4000; //This is the basic environmental brightness variables, please check your own brightness values, fill out here is slightly greater than the measured value of the data but the data is less than the light

void setup() {
  pinMode(analogInPin, INPUT);
  for(int i=3; i<=6;i++)          //Set the I/O port 2 - 5 to output mode.

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);
if (sensorValue>=1000)             
  SerialUSB.print("sensorValue = ");


When the light is very weak, lower the set minimum value, all the lights are off. With the increase of light, reach to a set level would light up an LED, to achieve the effect of instruction. Actually LED lamp has been flashing, because in order to make the light intensity is not a certain level, to put out the light of the level, directly after the lights out immediately, with no delay in the implementation process, as long as the grade, circulation processing, so it looks as if always on.