日常の進捗

行為と記録とその習慣化

Tinkercad Circuitsで電子回路のシミュレート

Tinkercadで作ったLEDとボタンのスケッチ。

www.tinkercad.com

f:id:takawo:20170802062653g:plain

const int led0 = 13;
const int led1 = 12;
const int led2 = 11;

const int button0 = 10;
const int button1 = 9;
const int button2 = 8;

int val0 = 0;
int val1 = 0;
int val2 = 0;

void setup() {
  pinMode(led0, OUTPUT);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(button0, INPUT);
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
}

void loop() {
  
  val0 = digitalRead(button0);
  if(val0 == HIGH){
    digitalWrite(led0,HIGH);
  }else{
    digitalWrite(led0,LOW);  
  }
  
  val1 = digitalRead(button1);
  if(val1 == HIGH){
    digitalWrite(led1,HIGH);
  }else{
    digitalWrite(led1,LOW);  
  }

  val2 = digitalRead(button2);
  if(val2 == HIGH){
    digitalWrite(led2,HIGH);
  }else{
    digitalWrite(led2,LOW);  
  }
  
  delay(10);
}