kusakari_motor
読み取り中…
検索中…
一致する文字列を見つけられません
main.cpp
[詳解]
1#define PIN_DIR 7
2#define PIN_PWM 5
3#define PIN_VOL A0
4
5void setup() {
6 // put your setup code here, to run once:
7 Serial.begin(9600);
8
9 pinMode(PIN_DIR, OUTPUT);
10 pinMode(PIN_PWM, OUTPUT);
11 analogWrite(PIN_PWM, 0);
12}
13
14void loop() {
15 // put your main code here, to run repeatedly:
16 int time_data = millis();
17
18 if((time_data % 1000) == 0) {
19 int second = time_data / 1000;
20 Serial.print(second);
21 }
22
23 int value = analogRead(PIN_VOL); //0 to 1023
24 float value_ = float(value) / 1023 * 255 * 0.75; //0 to 255 * 0.75
25 int pwm = int(value_);
26 Serial.print("Value: ");
27 Serial.print(value);
28 Serial.print(" pwm: ");
29 Serial.println(pwm);
30 digitalWrite(PIN_DIR, LOW);
31 analogWrite(PIN_PWM, pwm);
32
33}
#define PIN_PWM
void setup()
#define PIN_VOL
#define PIN_DIR
void loop()