//Fab Academy 2024 - Fab Lab León //Textile Flexure Sensor //FabriXiao //XIAO RP2040 int sensorPin = A0; // analog input pin to hook the sensor to A0 or 26 int sensorValue = 0; // variable to store the value coming from the sensor int ledPin = D10; // LED connected to pin D10 void setup() { Serial.begin(115200); // initialize serial communications pinMode(ledPin, OUTPUT); // set the LED pin as an output } void loop() { sensorValue = analogRead(sensorPin); // read the value from the sensor sensorValue = map(sensorValue, 600, 1024, 0, 1024); Serial.println(sensorValue); // print value to Serial Monitor // Map the sensor value to a PWM range (0-255) for LED brightness int ledBrightness = map(sensorValue, 600, 1024, 0, 255); analogWrite(ledPin, ledBrightness); // set LED brightness delay(500); // short delay so we can actually see the numbers }