Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int x = 0;
- void setup() {
- pinMode(3, OUTPUT);
- pinMode(5, OUTPUT);
- pinMode(A0, INPUT);
- Serial.begin(9600);
- }
- void loop() {
- x = analogRead(A0);
- if (x < 490){
- analogWrite(3, ((x-512)*(-1))/2);
- }
- else{
- analogWrite(3, 0);
- }
- if (x>530){
- analogWrite(5, (x-512)/2);
- }
- else{
- analogWrite(5, 0);
- }
- x=510;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement