/*Emma Pareschi, * with this sketch we read the analog sensor connected to pin analog_sensor_pin, * we map the value and we use it to control the Led */ int analog_sensor_pin = A0; //change the pin, where the sensor is connected? int analog_sensor_value = 0; int led_pin = 3; void setup() { // put your setup code here, to run once: pinMode(analog_sensor_pin, INPUT); pinMode(led_pin, OUTPUT); Serial.begin(9600); ! } void loop() { // put your main code here, to run repeatedly: analog_sensor_value = analogRead(analog_sensor_pin); //read the Voltage of the pin sensor analog_sensor_value = map(analog_sensor_value, 230, 130, 0, 255); //we change the range analog_sensor_value = constrain(analog_sensor_value, 0, 255); //we apply the limits analogWrite(led_pin, analog_sensor_value); //we use the mapped value to control the Led Serial.println(analog_sensor_value); // print the value on the Serial monitor delay(10); }