Super Fast Super Easy Metal/Mental Touch Sensor Guide!
by Steam_Clown in Circuits > Arduino
1747 Views, 2 Favorites, 0 Comments
Super Fast Super Easy Metal/Mental Touch Sensor Guide!
Wondering how to use a metal or touch sensor with an Arduino? Well, we've got your back!
Type in Code!
Type in the following code.
const int SensorPin=7;
//const int SensorPin=7;
//Level input ports
const int analogIn = A0;
const int ledPin = 13;
int SensorState=0;
int analogVal = 0;
void setup()
{ pinMode
(SensorPin,INPUT);
pinMode(ledPin,OUTPUT);
} void loop()
{ analogVal = analogRead(analogIn);
SensorState=digitalRead(SensorPin);
if(SensorState==HIGH)
{ digitalWrite(ledPin,HIGH);
} else { digitalWrite(ledPin,LOW); }
} const int analogIn = A0;
const int ledPin = 13;
int SensorState=0;
int analogVal = 0;
void setup()
{ pinMode(SensorPin,INPUT);
pinMode(ledPin,OUTPUT);
} void loop()
{ analogVal = analogRead(analogIn);
SensorState=digitalRead(SensorPin);
if(SensorState==HIGH)
{ digitalWrite(ledPin,HIGH);
} else { digitalWrite(ledPin,LOW);
}
}
Upload to Arduino!
Upload using the upload button on the window.
Begin Wiring.
Analog to A0, GND to ground, 5V to 5V, and pin to 13. DONE!
Admire Your Working Sensor!
Check your console for it detecting stuff. Good job, you now know how to use a metal/mental sensor! Good luck with application to other things!