[마이크로비트] 버튼 응용 예제 (마이크로비트 기본 예제)

버튼을 눌러 숫자 맞추는 예제

2a391e1f02ef28f88f76c0918e14d3c4.png
 

자바 스크립트

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

let d=Math.randomRange(0,2)
basic.showString("START")
basic.forever(function(){
  if(input.buttonIsPressed(Button.AB)){
    if(d==0){
      basic.showString("bingo")
      control.reset()
    } else{
      basic.showString("C")
    }
  } else if(input.buttonIsPressed(Button.A)){
    if(d==1){
      basic.showString("bingo")
      control.reset()
    } else{
      basic.showString("A")
    }
  } else if(input.buttonIsPressed(Button.B)){
    if(d==2){
      basic.showString("bingo")
      control.reset()
    } else{
      basic.showString("B")
    }
  }
})


0
0
이 글을 페이스북으로 퍼가기 이 글을 트위터로 퍼가기 이 글을 카카오스토리로 퍼가기 이 글을 밴드로 퍼가기

임베디드 보드

번호 제목 글쓴이 날짜 조회수
게시물이 없습니다