LogoLogo
  • Documentation Pages
  • About Minor Makers Lab
  • Documentation templates
    • Recipe template
    • Label templates
    • Ingredient template
  • Projects
    • Project overview
      • Gelance Cushion - Andrei Motian
      • Landscapes for Warhammer - Dusanka Prvulovic
      • Bioplastic Filters: An Analogue Photoshop - DaniĆ«l van Kesteren
      • Hyperdisposables - Anoush Mazloumian
      • Project Stop Touching - Summer Danoe
      • Foam For Material Activists - Laura Velgersdijk
      • DateKleed - Duncan van Norden
      • One Size Hurts All - Kaz Bison
      • Biodegradable Packaging Bags - Kim Sinke
      • DIY Faceguards - Thijs Uffen
      • Bioplastics on a Rainbow Spectrum - Desiree van Dam
      • Beyond Humanity - Britt de Heer
  • Coursework
    • Britt
      • research zine text
      • Week 11
      • Week 12 / 13
      • Week 14
      • 1 ) Kick-Off
        • Grafische Werkplaats Amsterdam
        • Safetyzine
      • 2 ) Electronics: Connecting Materials
      • 4 ) Cutting Supersurfaces
        • Zine: Art Approach
        • Furry Sample Book
      • 5 ) Additive Manufacturing
      • 6 ) Untoolkit: Electronic Inputs
      • 7 ) Transforming: Moulding and Casting with Bioplastics
      • 8 ) Untoolkit: Electronic Outputs
    • Andrei
      • Week 1
        • GWA
        • Textielmuseum
        • Safetyzine
      • Week 2
        • Ohm's Law & circuits
        • Speaker on denim
      • Week 4
        • Inflatables 2D to 3D
        • Smooth to sharp with polypropylene
      • Week 5
        • Making a switch for the laser cutter in Fusion360
        • Designing and 3D printing molds
      • Week 6
        • Wearable switch for sound
        • Analog Sensor
      • Week 7
        • Home materials
        • Making bioplastics
        • Material properties
      • Week 8
        • Virtual Swatch
        • Processing
        • RGB LED
      • Project weeks 11 - ?
        • Week 11: Kick-off
          • Brainstorm Session
          • 5 min pitch
          • Trail of Evidence
          • Proposal
        • Week 12: Experimenting
          • Research workout materials
          • First Experiment
          • Trail of Evidence
        • Week 13: Project Work
          • Insights
          • Reframing session with Laura
          • Trail of Evidence
        • Week 14: Reframing
          • Reflective design method
          • Going bigger
          • Trail of Evidence
        • Week 15
          • Highlights photo's
          • Reframing, research & insights
          • Trail of Evidence
        • Week 16
          • Going even bigger
          • Trail of Evidence
        • Week 17
          • Trail of Evidence
        • Project
    • Anoush
      • Week 11-19
        • Week 11 | project kick-off
        • Week 14 | First experiments
        • Week 15 | Progress presentation
        • Last reframing session
        • Trail of Evidence
      • Week 1-8
        • Overall Reflection
        • Week 8 | Untoolkit - Electronic Outputs
        • Week 7 | Transforming bioplastics
        • Week 6 | Untoolkit - Electronic inputs
        • Week 5 | Additive Manufacturing
        • Week 4 | Cutting Supersurfaces
        • Week 3 | Reading Week
        • Week 2 | Electronics: Connecting Materials
        • Week 1 | Kick-off
    • DaniĆ«l
      • Week 20: Expo Week
      • Week 19: Project Week 9
      • Week 18: Project Week 8
      • Week 17: Project Week 7
      • Week 1: Kick-Off
      • Week 2: Electronics and Connecting Materials
        • Part I: The Basics and Recreating Circuits
        • Part II: The Making of the Speaker
        • Part III: Testing the speaker
      • Week 3: Reading Week
      • Week 4: Processes & Collaboration
        • Part I: exploring the words
        • Part II: experimenting with the laser cutter
      • Week 5: Critical Making 3D
        • Part I: Creating the injection mold
        • Part II: Creating the two-part mold
        • Part III: Printing the designs
      • Week 6: Electronics & Open Design
      • Week 7: Bioplastics
        • Material Properties Sheet
        • The Ma2E4 Toolkit
        • The Ma2E4 Toolkit (second bioplastic)
        • An application for the bioplastic
      • Week 8: Interfaces & Algorithmic Bias
      • Week 9: Documentation Week
      • Week 10: Assessments
      • Week 11: Project Kick-Off
      • Week 12: Recess
      • Week 13: Project Week 2
      • Week 14: Project Week 3
      • Week 15: Project Week 4
      • Week 16: Project Week 5
        • Presentation Preparation
    • Desiree
      • Summaries
      • Kick-off
      • Week 1 - Safety Zine
      • Week 2-3 Electromagnets
      • Week 4 - Cutting Supersurfaces
      • Week 5 - Additive Manufacturing
      • Week 6 - Untoolkit: Electronic Inputs
      • Week 7 - Transforming: Molding and Casting with Bioplastics
      • Week 8 - Untoolkit: Electronic Outputs
      • Trail of Evidence
      • Website
      • Material Archive
      • Week 11 - Choose a project
      • Week 12 - 13
      • Week 14
      • Week 15
      • Week 16
      • Week 17
      • Week 18
      • Week 19
    • Duncan
      • Week 1: Kick-Off
        • Masterclass Studio Overvelde
        • Workshop letterpress
        • Textielmuseum Tilburg
        • Meet the Makers - introduce yourself
        • Safetyzine
        • extraĀ“s
      • Week 2: Electronics: Connecting Materials
        • Zine: Kits & Open sources
      • Week 3: Reading week
      • Week 4: Cutting Supersurfaces
        • Zine:
      • Week 5: Additive Manufacturing
        • Workshop Amstelstation
        • Zine: 3D-printers & Being editors
        • Overall conclusion
      • Week 6: Untoolkit (Inputs)
        • Together w/ Loes
        • Zine: week 6
        • ExtraĀ“s
      • Week 7: Transforming
        • Zine: Social issues
        • extra's
      • Week 8: Untoolkit (Outputs)
        • Zine: Does being a 'maker' makes you a better civilian?
        • extraĀ“s: week 8
      • Week 9: Reflection
        • Zine:
        • extra's (week 9)
      • Week 10: Assessments
        • Zine:
      • Week 11
        • Makers skills & attitude
        • Design research skills
        • Collaborative learning
      • Week 12
        • Maker skills & attitude
        • Design research skills
        • Collaborative learning
      • Week 13
        • Scenario
        • Maker skills & attitude
        • Design research skills
        • Collaborative learning
      • Week 14
      • Week 15
        • Materialen lijst
        • Lijst met verschillende manier van connecten
        • Scenarios
        • Inspiratie voor vormen
        • Concrete voorbeelden tekenen
        • Samples / plan schrijven om te MAKEN!!
        • Kleuren inspiratie
      • Week 16
      • Week 18
        • Samples
        • The making of Samples
        • Inspiratie
        • Benodigdheden Woensdag 03/06/20
        • Inspiratie foto serie
        • Digitale tekeningen
      • Week 19
      • Week 20
    • DuÅ”anka
      • Week 1 - 8
        • 1 | Kick-Off
          • 2 | Electronics: Connecting Materials
            • Assignment 0 - Zine
            • Assignment 1 - Paper circuit
            • Assignment 2 - Soft speaker
          • Assignment 1
          • Assignment 2
        • 4 | Cutting Supersurfaces
          • Assignment 0 - Zine
          • Assignment 1 - Sample Book
        • 5 | Additive Manufacturing
          • Assignment 0 - Zine
          • Assignment 1 - Mold documentation
          • Assignment 2 - Molds
        • 6 | Untoolkit: Electronic Inputs
          • Assignment 0 - Zine
          • Assignment 1 - Antiprimadonna's
          • Assignment 2 - Working circuit
        • 7 | Transforming: Molding and Casting with Bioplastics
          • Assignment 0 - Zine
          • Assignment 1 - Intro
            • Bioplastics
            • Experiential toolkit
            • Material properties sheet
            • Future applications
            • Reflection
        • 8 | Untoolkit: Eelectronic Outputs
          • Assignment 0 - Zine
          • Assignment 1 - Working circuit
      • 11 | Projects Kick-Off
        • Trail of Evidence
      • 12 | First experiments
        • Trail of Evidence
        • Building the board
      • 13 | Project Work
        • Trail of Evidence
        • Building scenery
      • 14 | Reframing
        • Trail of Evidence
        • Game ideation
      • 15 | Making fake water
        • Trail of Evidence
      • 16 | Making a cherry blossom tree
        • Trail of Evidence
      • 17 | Expo plan & Clouds
        • Trail of Evidence
      • 18 | Research zine & Coffee soil
        • Research zine
      • 19 | Research zine 2.0
    • Kaz
      • 1 | Kick-Off
      • 2 | Electronics: Connecting Materials
        • Assignment 0 - Zine
        • Assignment 1 - Paper circuits
        • Assignment 2 - Building a speaker
      • 4 | Cutting Supersurfaces
      • 5 | Additive Manufacturing
      • 6 | Untoolkit: Electronic Inputs
      • 7 | Transforming: Molding and Casting with Bioplastics
      • 8 | Untoolkit: Electronic Outputs
      • 11 - 20 | Project: Face Mask Strap
        • 11 | Kick-Off / Pitch
        • Trail of Evidence
        • 15 | Midterm presentation
    • Kim
      • 1 - Introweek
        • Discussion notes
        • Try out zine - Week 1
      • 2 - Electronics: Connecting Materials
        • Zine - Week 2
      • Zine - Week 3
      • 4 - Cutting Supersurfaces
        • The making of: The Sample Book
        • Dense - Clear final sample book
        • Zine - Week 4
      • 5 - Additive Manufacturing
        • Understanding Fusion 360
        • Understanding Cura
        • Understanding the 3D Printer
        • Zine - Week 5
      • 6 - Coronaweek Untoolkit: Electronic Inputs
        • LDR LED connection with Arduino
        • Zine - Week 6
      • 7 - Coronaweek Transforming: Molding and Casting with Bioplastics
        • Material properties sheet + Experiential toolkit
        • Future Bioplastic concept
        • Zine - Week 7
      • 8 - Untoolkit: Electronic Outputs
        • Output swatch
        • Zine - Week 8
      • Project Page Biodegradable Packaging Bags
      • 11 - Project proposal week
        • Trial of evidence week 11
      • 12&13 - Project Bioplastic Consumables
        • Trial of evidence week 12&13
      • 14 - Reframing week
        • Trial of evidence week 14
      • 15 - Project work
        • Trial of evidence week 15
      • 16 - Reframing and expo prep
        • Trial of evidence week 16
        • 16 - The first test
      • Material Sample 1
      • 17 - Project work
        • 17 - Ironing a bioplastic bag
        • 17 - New method for sticking a bioplastic bag together
        • 17 - How to compost?
        • Trial of evidence week 17
      • 18 - Trial of Evidence
      • 19 - Trial Of Evidence
      • 20 - Trial Of Evidence
      • 21 - Final Expostion
    • Laura
      • Week 1: Kick off
      • Week 2: Electronics: connecting materials
      • Week 4: Cutting Supersurfaces
      • Week 5: Additive Manufacturing
      • Week 6: Untoolkit: Electronic inputs
      • Week 7: Transforming Molding and Casting with Bioplastics
      • Foam For Material Activists
        • How to protect?
        • To find a material
        • Foam
        • Trail of Evidence
        • Midterm presentations
    • Summer
      • Foto's
      • Midterm presentation
      • Project: Stop touching
        • Project Proposal
        • Inspirational projects
      • Cutting Supersurfaces
      • Additive Manufacturing
      • Molding and Casting with Bioplastics
        • Creating natural dyes
        • Created bioplastics
      • Electronic input
      • Electronic output
    • Thijs
      • Week 1 - Kickoff
      • Week 2 - Electronics : connecting materials
      • Week 2 - Workshop : debugging circuits
      • Week 2 - Making a speaker
      • Week 3 - Processes & Collaboration
      • Week 4 - Cutting supersurfaces
      • Week 4 - Zine editor
      • Week 5 - Additive manufacturing
      • Week 6 - Untoolkit: Electronic Inputs
      • Week 7 - Transforming: Molding and Casting with Bioplastics
        • Ma2E4 Toolkit
        • Future applications & reflection
      • Week 8 - Untoolkit : electronic outputs
      • Week 11 - Project kickoff
      • Week 12 - First experiments
      • Week 13 - Project work
      • Week 14 - Reframing & trail of evidence
        • Reframing : additional research
        • Shopping list
        • Testing bioplastic material
      • Week 15
      • Weeks 15 - 20
      • Expo prep
  • CLASS NOTES
    • Zine documentation (collaborative doc)
    • Discussions week 2-8
      • Week 02 - Connecting Materials
      • Week 04 - Cutting Supersurfaces
      • Week 05 - Additive Manufacturing
      • Week 06 - Untoolkit Electronics Inputs
      • Week 07 - Transforming Bioplastics
Powered by GitBook
On this page
  • Step 1
  • Step 2
  • Step 2 fersh start
Export as PDF
  1. Coursework
  2. Kim
  3. 6 - Coronaweek Untoolkit: Electronic Inputs

LDR LED connection with Arduino

Week 6 and 8

Trying to connect a LDR to a LED with NodeMCU

The first code from Loes I am going to try:

/*
  created by David Cuartielles
  modified 30 Aug 2011
  By Tom Igoe
  modified 13 March 2020 
  By Loes Bogers
  This example code is in the public domain.
  http://www.arduino.cc/en/Tutorial/AnalogInput
*/

int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = D1;      // select the pin for the LED that has PWM (~) e.g pin D1 on Node MCU
int sensorValue = 0;  // variable to store the value coming from the sensor
int mappedValue = 0;  //store the mapped values

void setup() {

  // initialize serial communication with computer:
  Serial.begin(115200);     //make sure it matches with the number in the serial port

  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);
  pinMode(sensorPin, INPUT);
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);

//// FIND MIN & MAX RANGE FIRST, THEN COMMENT OUT
  // print values to serial to find lowest and highest values (min and max) in serial monitor
  Serial.println(sensorValue);      // met 10K voltage divider: bijv. range 100-850 zonder een fietslampje erbij (beter voor de video)

 /*    
//PUT THE VALUES YOU FOUND (YOUR_MIN, YOUR_MAX) INTO THE LINE BELOW (line 36)
//put your min value and max value (as seen in the monitor) and map to a range 0- 255 for output
  mappedValue = map(sensorValue, 100, 850, 0, 255); 

    // print values for debugging
    Serial.print("Old Value (no mapping) = ");
    Serial.print(sensorValue);
    Serial.print("\t");   // add a tab between the numbers
    Serial.print("New value (mapped) = ");
    Serial.println(mappedValue);

    // turn the ledPin on using the mappedvalue from the sensorpin
    analogWrite(ledPin, mappedValue);
*/

}

I tried to work with this schematic drawing of how the circuit should look like:

I made this out of it:

It didn't worked:

I find the LDR LED really difficult so I'll try some old codes I had and re-install my board.

Step 1

So I started with the basics again. Does my LED really works?

I ran an empty code to see if my LED really worked.

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

And it worked!

Step 2

I went back to the slides and found this image:

I wanted to run the same code i did previously and came across this error:

The port of my NodeMCU is not found. I checked my settings and also saw that the serial print speeds were also not the same, that's why I couldn't run my code and open the serial monitor port. The serial port speed was around 4200. So I set everything back to 115200 and restarted my NodeMCU. It now connects again.

But when I run the code again this happend:

Well nothing happened. I send the code to my NodeMCU and I didn't got any variables. I run it again and it still didn't worked, so I started debugging my board.

I changed every piece of cable and finally I found out what was wrong and why my LDR sensor didn't gave any values: The LDR resistor had to be on the GND pin and I think it was not really pushed in it real good.

My values are: 3 to 4 and sometimes 5. I still don't really trust it, but it does shows values, but I know it are not the right values.

I still don't trust the values but I'll go on with the code. So I adjusted my Min and max values on line 36 to 3 and 4.

/*
  created by David Cuartielles
  modified 30 Aug 2011
  By Tom Igoe
  modified 13 March 2020 
  By Loes Bogers
  This example code is in the public domain.
  http://www.arduino.cc/en/Tutorial/AnalogInput
*/

int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = D1;      // select the pin for the LED that has PWM (~) e.g pin D1 on Node MCU
int sensorValue = 0;  // variable to store the value coming from the sensor
int mappedValue = 0;  //store the mapped values

void setup() {

  // initialize serial communication with computer:
  Serial.begin(115200);     //make sure it matches with the number in the serial port

  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);
  pinMode(sensorPin, INPUT);
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);

//// FIND MIN & MAX RANGE FIRST, THEN COMMENT OUT
  // print values to serial to find lowest and highest values (min and max) in serial monitor
  Serial.println(sensorValue);      // met 10K voltage divider: bijv. range 100-850 zonder een fietslampje erbij (beter voor de video)

     
//PUT THE VALUES YOU FOUND (YOUR_MIN, YOUR_MAX) INTO THE LINE BELOW (line 36)
//put your min value and max value (as seen in the monitor) and map to a range 0- 255 for output
  mappedValue = map(sensorValue, 3, 4, 0, 255); 

    // print values for debugging
    Serial.print("Old Value (no mapping) = ");
    Serial.print(sensorValue);
    Serial.print("\t");   // add a tab between the numbers
    Serial.print("New value (mapped) = ");
    Serial.println(mappedValue);

    // turn the ledPin on using the mappedvalue from the sensorpin
    analogWrite(ledPin, mappedValue);


}

And my serial still says a lot of thinks with a really high speed:

After I ran this code my computer crashed.

Step 2 fersh start

I still didn't get why my LDR sensor was nog working. So I asked my boyfriend if he wanted to help me with a puzzle. I gave him the image of how the board must look like and all the necessities. He has no knowledge abut coding, adruino or anything like that, so it was a fresh start. He made the board look exactly as the image that I showed, which I had done in my previous attempts. I ran the code, and it worked! What!

I used the min value 560 and max value 611. It worked, but it's crashes my laptop. So I'm going to try it out with a more wider min max value, maybe that will work better.

/*
  created by David Cuartielles
  modified 30 Aug 2011
  By Tom Igoe
  modified 13 March 2020 
  By Loes Bogers
  This example code is in the public domain.
  http://www.arduino.cc/en/Tutorial/AnalogInput
*/

int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = D2;      // select the pin for the LED that has PWM (~) e.g pin D1 on Node MCU
int sensorValue = 0;  // variable to store the value coming from the sensor
int mappedValue = 0;  //store the mapped values

void setup() {

  // initialize serial communication with computer:
  Serial.begin(115200);     //make sure it matches with the number in the serial port

  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);
  pinMode(sensorPin, INPUT);
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);

//// FIND MIN & MAX RANGE FIRST, THEN COMMENT OUT
  // print values to serial to find lowest and highest values (min and max) in serial monitor
  Serial.println(sensorValue);      // met 10K voltage divider: bijv. range 100-850 zonder een fietslampje erbij (beter voor de video)
  
//PUT THE VALUES YOU FOUND (YOUR_MIN, YOUR_MAX) INTO THE LINE BELOW (line 36)
//put your min value and max value (as seen in the monitor) and map to a range 0- 255 for output
  mappedValue = map(sensorValue, 560, 611, 0, 255); 

    // print values for debugging
    Serial.print("Old Value (no mapping) = ");
    Serial.print(sensorValue);
    Serial.print("\t");   // add a tab between the numbers
    Serial.print("New value (mapped) = ");
    Serial.println(mappedValue);

    // turn the ledPin on using the mappedvalue from the sensorpin
    analogWrite(ledPin, mappedValue);


}

Trying it out with a flash light the values wil be min 560 and max 955:

/*
  created by David Cuartielles
  modified 30 Aug 2011
  By Tom Igoe
  modified 13 March 2020 
  By Loes Bogers
  This example code is in the public domain.
  http://www.arduino.cc/en/Tutorial/AnalogInput
*/

int sensorPin = A0;    // select the input pin for the potentiometer
int ledPin = D2;      // select the pin for the LED that has PWM (~) e.g pin D1 on Node MCU
int sensorValue = 0;  // variable to store the value coming from the sensor
int mappedValue = 0;  //store the mapped values

void setup() {

  // initialize serial communication with computer:
  Serial.begin(115200);     //make sure it matches with the number in the serial port

  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);
  pinMode(sensorPin, INPUT);
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);

//// FIND MIN & MAX RANGE FIRST, THEN COMMENT OUT
  // print values to serial to find lowest and highest values (min and max) in serial monitor
  Serial.println(sensorValue);      // met 10K voltage divider: bijv. range 100-850 zonder een fietslampje erbij (beter voor de video)
  
//PUT THE VALUES YOU FOUND (YOUR_MIN, YOUR_MAX) INTO THE LINE BELOW (line 36)
//put your min value and max value (as seen in the monitor) and map to a range 0- 255 for output
  mappedValue = map(sensorValue, 560, 611, 0, 255); 

    // print values for debugging
    Serial.print("Old Value (no mapping) = ");
    Serial.print(sensorValue);
    Serial.print("\t");   // add a tab between the numbers
    Serial.print("New value (mapped) = ");
    Serial.println(mappedValue);

    // turn the ledPin on using the mappedvalue from the sensorpin
    analogWrite(ledPin, mappedValue);


}

It worked a lot smoother then the code with a closer min and max value.

Previous6 - Coronaweek Untoolkit: Electronic InputsNextZine - Week 6

Last updated 5 years ago

Schematic drawing from Loes
LDR test 1
error
LDR Settings
USB port of the NodeMCU not found
Nothing
LDR values
Try out 2
Values
on off
New values no flat light - flash light
Filmed with flash light