int volt = 0; int threshold = 160; void setup() { // put your setup code here, to run once: pinMode(10, OUTPUT); pinMode(6, INPUT_PULLUP); } void loop() { // put your main code here, to run repeatedly: volt = analogRead(6); volt = map(volt,200,400,0,255); analogWrite(10, volt); }