1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ラズパイセットアップ~Lチカまで

Posted at

#用意するもの

  • RaspberryPi2 Model B
  • ブレッドボード
  • USB microB 電源アダプタ
  • micro SD 16GB
  • Ethernetケーブル
  • ジャンパーワイヤー
  • LED
  • 抵抗1kΩ
  • ラジオペンチ

#手順
##1.SDの用意
SDをフォーマット(FAT32)
https://www.disk-partition.com/jp/articles/how-to-repair-micro-sd-16gb-card-it-shows-31mb.html

Raspbianをインストール
https://qiita.com/Choke222/items/6f12f3f3a0eef10e94cb

##2.SSH接続
https://qiita.com/hikobotch/items/a33fc77114a4963cc68b

##3.Lチカ
以下の配線図を作成
https://qiita.com/t114/items/89be2c866724e193a5cb

以下の方法で手動Lチカ
https://tool-lab.com/2013/12/raspi-gpio-controlling-command-1/

$ sudo echo 23 > /sys/class/gpio/export
$ ls /sys/class/gpio/
export     gpio23/    gpiochip0/ unexport
$ cd /sys/class/gpio/gpio23
$ ls
active_low  device  direction  edge  power  subsystem  uevent  value
$ sudo echo out > directio
$ sudo echo 0 > value
$ sudo echo 1 > value

光った!少し感動。

##4.プログラムからLチカ
http://forestofazumino.web.fc2.com/turtlereal/turtlereal_gpio.html

$ mkdir workdir
$ cd workdir/
$ ls
$ vi Lchika.c
Lchika.c
void main (){
  int fd = open("/sys/class/gpio/export", O_WRONLY);
  write(fd, "23", 2);
  close(fd);
  sleep(1);
  fd = open("/sys/class/gpio/gpio23/direction", O_WRONLY);
  write(fd, "out", 3);
  close(fd);
  fd = open("/sys/class/gpio/gpio23/value", O_WRONLY);
  while(1){
    write(fd, "1", 1);
    sleep(1);
    write(fd, "0", 1);
    sleep(1);
  }
  close;(fd);
}
$ gcc Lchika.c -o test
$ ls
$ ./test

1秒ごとに光った!

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?