you practice basic with arduino

Practice 20

To talk back the control system of the ignition of the LED based on
position of the potentiometer. To consider the following program

 

//Variables global
//Variable constant for the pins
const int potPin = A0; //selects the pin of entrance for the potentiometer
const int ledPin = 9; //selects pin 9 for the LED
//variable that stores the data
int potValue = 0; //variable to store the values of potentiometer 0
1023
int bright = 0; //variable that stores the value of the sensorial mapping 0-255
void setup () \ {
//nothing that to declare in setup

}
void loop () \ {
//reads the value of the sensor 0-1023
potValue = analogRead (potPin);
//mapea the value on scale 0-255
bright = map (potValue, 0, 1023, 0, 255);
//we wrote the value in analogical in the LED
analogWrite (ledPin, bright);
}

2. To try to change to the slope and rise times of the LED in the first one
system by means of variation of delay and changes in
increase of the repetition curl. To take into account the following code

const int ledPin = 9; Connected //LED to Pin 9
void setup () \ {
//nothing that to declare in the set up
}
void loop () \ {
//Ignited gradual of the LED in 2,5s
for (int fadeValue = 0; fadeValue < = 255; fadeValue += 5) \ {
analogWrite (ledPin, fadeValue); //establishes the value from 0 to 255
delay (50); //hopes of 50 ms
}
//Dull gradual of the LED in 2,5
for (int fadeValue = 255; fadeValue > = 0; fadeValue - = 5) \ {
analogWrite (ledPin, fadeValue); //establishes the value from 255 to 0
delay (50); //hopes of 50 ms
}
}

Practice 21. Crepuscular switch

  1. The value of the LDR monitors. To try how it influences the use of different
    resistance (1k- 10k) in the value of reading. To choose most suitable,
    that one that us of a greater rank, for our conditions
  2.  To talk back the system set out in the video
  3.  To realise a system that shows the light intensity by means of 4
    leds. So that to low light intensity one only illuminates a LED and a
    measurement that is raising the intensity more are illuminated leds
  4.  To add a switch who connects and disconnects the system

//variable constant for the pins
const int ldrPin = A0; //establishes the pin of the LDR
const int ledPin = 12; //establishes the pin of the red LED
//variable that can change
int ldrValue = 0; //variable to store the value of the LDR
int ldrlevel=200; //level of change of the value of the LDR
void setup () \ {
//establishes the LED as an exit
pinMode (ledPin, OUTPUT);
}
void loop () \ {
//reads the value of the sensor
ldrValue = analogRead (ldrPin);
//if the S-value smaller ignites the LEDs
if (ldrValue < ldrlevel) \ {
digitalWrite (ledPin, HIGH);
}
//but extinguishes them
else \ {
digitalWrite (ledPin, LOW);
}
}

assembly ldr in arduino

Practice 22 the note of this practice will be evaluated as if outside an EXAMINATION

To change the potentiometer by a LDR actually 20 and to do that the LED
it is illuminated in inverse proportion to the light intensity. Much light little
intensity, little light much illumination.

Practice 23 and 24

Practice 25