目的
教科書的プログラムを書いて遊ぶ
一部教科書から逸脱した毒も込み(2ビット右シフト)
//PWM_ Potentiometer_UNO_1
#include <Arduino.h>
//初期化処理
void setup()
{
Serial.begin(9600); //シリアルポートの初期化
} //setup
//メインループ
void loop()
{
//センサーの値を読み込む
int sensorValue = analogRead( A0 );
//センサーのADC値をPWMの値に変換
int outputValue = map(sensorValue, 0, 1024, 0, 256);
//Debug
//int outputValue = sensorValue >> 2;
//PWMの出力
analogWrite( 5 , outputValue );
//PWMの値の表示
Serial.print("PWM = [");
Serial.print(outputValue);
Serial.print("]");
Serial.println();
//0.5秒の待ち
delay(500);
} //loop