Namikhyungledel
Published

digitalRead and analogRead

The digitalRead and analogRead of an Arduino.

BeginnerWork in progress1,004
digitalRead and analogRead

Things used in this project

Story

Read more

Code

analogRead

Arduino
int lp = 11;
int iv;
int br;

void setup(){
  pinMode(lp, OUTPUT);
}

void loop(){
  iv = analogRead(A0);

  br = map(iv, 0, 1023, 0, 255);
 
  analogWrite(lp,br);
} 

digitalRead

Arduino
int LP = 13;
int SP1 = 2;
int SP2 = 8;
int SV1;
int SV2;

void setup() {
  pinMode(LP,OUTPUT);
  pinMode(SP1,INPUT);
  pinMode(SP2,INPUT);
}

void loop() {
  SV1 = digitalRead(SP1);
  SV2 = digitalRead(SP2);
  if(SV1 == LOW) {
    digitalWrite(LP,HIGH);
  }
  if(SV2 == HIGH) {
    digitalWrite(LP,HIGH);
  }
  digitalWrite(LP,LOW);
} 

Credits

Namikhyun
5 projects • 2 followers
I do the Arduino programming. But he is still a beginner. A tremendous beginner. Expect, people.
Contact
gledel
100 projects • 116 followers
Looking back on my childhood, I was happy when I was making something and I was proud of myself. "Making is instinct!"
Contact

Comments

Please log in or sign up to comment.