@@ -46,6 +46,23 @@ func kickCheck(chkicker chan bool) {
4646
4747func main () {
4848
49+ err := rpio .Open ()
50+ if err != nil {
51+ log .Fatal ("Error: " , err )
52+ }
53+
54+ //button が押されているか確認
55+ button1 := rpio .Pin (22 )
56+ button1 .Input ()
57+ button1 .PullUp ()
58+
59+ if button1 .Read ()^ 1 == rpio .High {
60+ log .Println ("Button1 is pressed. Start Robot Control Mode" )
61+ isControlByRobotMode = true
62+ }
63+
64+ rpio .Close ()
65+
4966 //Hostnameを取得する
5067 cmd := exec .Command ("hostname" )
5168 out , err := cmd .Output ()
@@ -98,6 +115,46 @@ func main() {
98115
99116 }
100117
118+ if isControlByRobotMode {
119+ log .Println ("Robot Control Mode is ON" )
120+ out = []byte ("localuser\n " )
121+ }
122+
123+ if string (out ) == "localuser\n " {
124+ //ラズパイのGPIOのメモリを確保
125+ err := rpio .Open ()
126+ CheckError (err )
127+ buzzer := rpio .Pin (13 )
128+ buzzer .Mode (rpio .Pwm )
129+ buzzer .Freq (1175 * 64 )
130+ buzzer .DutyCycle (16 , 32 )
131+ time .Sleep (1000 * time .Millisecond )
132+ buzzer .DutyCycle (0 , 32 )
133+ time .Sleep (1000 * time .Millisecond )
134+
135+ button1 := rpio .Pin (22 )
136+ button1 .Input ()
137+ button1 .PullUp ()
138+
139+ if button1 .Read ()^ 1 == rpio .High {
140+ isControlByRobotMode = true
141+ log .Println ("Robot Control Mode is ON" )
142+ buzzer .Freq (1244 * 64 )
143+ buzzer .DutyCycle (16 , 32 )
144+ time .Sleep (100 * time .Millisecond )
145+ buzzer .DutyCycle (0 , 32 )
146+ time .Sleep (100 * time .Millisecond )
147+ buzzer .Freq (1244 * 64 )
148+ buzzer .DutyCycle (16 , 32 )
149+ time .Sleep (100 * time .Millisecond )
150+ buzzer .DutyCycle (0 , 32 )
151+ time .Sleep (100 * time .Millisecond )
152+
153+ } else {
154+ os .Exit (0 )
155+ }
156+ }
157+
101158 //自動アップデート
102159 go confirmAndSelfUpdate ()
103160 //GPIOの初期化
0 commit comments