Skip to content

Commit

Permalink
Add sample files (#1)
Browse files Browse the repository at this point in the history
Add sample files
  • Loading branch information
Shota Aoki authored Jul 7, 2020
1 parent 9eb5314 commit 635d30d
Show file tree
Hide file tree
Showing 57 changed files with 13,949 additions and 1 deletion.
26 changes: 26 additions & 0 deletions Arduino_Exercises/practice1/practice1.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Arduino_Exercises/practice1.ino
*
* Copyright(C) 2020 RT Corporation <support@rt-net.jp>
* All rights reserved.
*
* License: Apache License, Version 2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
*/

int LED_Pin= D13;

void setup() {
// put your setup code here, to run once:
pinMode(LED_Pin,OUTPUT);

}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED_Pin,HIGH); //LEDを点灯
delay(500); //0.5秒待つ
digitalWrite(LED_Pin,LOW); //LED消灯
delay(500); //0.5秒待つ
}
52 changes: 52 additions & 0 deletions Arduino_Exercises/practice10/practice10.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Arduino_Exercises/practice10.ino
*
* Copyright(C) 2020 RT Corporation <support@rt-net.jp>
* All rights reserved.
*
* License: Apache License, Version 2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
*/

int LINE_L2_Pin = A5;
int LINE_L1_Pin = A4;
int LINE_R1_Pin = A3;
int LINE_R2_Pin = A2;
int LED_Pin = D13;
int SW1_Pin = D7;
int SW2_Pin = D8;

int flag = 0;

void setup() {
// put your setup code here, to run once:
pinMode(LED_Pin,OUTPUT);
pinMode(SW1_Pin,INPUT_PULLUP);
pinMode(SW2_Pin,INPUT_PULLUP);
Serial.begin(115200);
}

void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(SW1_Pin)==LOW){
flag = 1;
delay(30);
while(digitalRead(SW1_Pin)==LOW);
delay(30);
}
if(digitalRead(SW2_Pin)==LOW){
flag = 0;
delay(30);
while(digitalRead(SW1_Pin)==LOW);
delay(30);
}
if (flag == 1){
Serial.printf("\n\r LL2=%d LL1=%d LR1=%d LR2=%d",
analogRead(LINE_L2_Pin),analogRead(LINE_L1_Pin),analogRead(LINE_R1_Pin),analogRead(LINE_R2_Pin));
}
digitalWrite(LED_Pin,HIGH);
delay(100);
digitalWrite(LED_Pin,LOW);
delay(100);
}
58 changes: 58 additions & 0 deletions Arduino_Exercises/practice11/practice11.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Arduino_Exercises/practice11.ino
*
* Copyright(C) 2020 RT Corporation <support@rt-net.jp>
* All rights reserved.
*
* License: Apache License, Version 2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
*/

int DIR_R_Pin = D12;
int DIR_L_Pin = D0;
int SW1_Pin = D7;
int SW2_Pin = D8;
int PWM_R_Pin = D11;
int PWM_L_Pin = D10;
int CW_R = LOW;
int CCW_R = HIGH;
int CW_L = HIGH;
int CCW_L = LOW;

int PWM =0;

void setup() {
// put your setup code here, to run once:
pinMode(DIR_R_Pin,OUTPUT);
pinMode(DIR_L_Pin,OUTPUT);

pinMode(SW1_Pin,INPUT_PULLUP);
pinMode(SW2_Pin,INPUT_PULLUP);

digitalWrite(DIR_R_Pin,CW_R);
digitalWrite(DIR_L_Pin,CW_L);

}

void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(SW1_Pin) == LOW){
delay(200);
PWM += 10;
if(PWM > 255){
PWM = 255;
}
analogWrite(PWM_R_Pin,PWM);
analogWrite(PWM_L_Pin,PWM);
}
if(digitalRead(SW2_Pin) == LOW){
delay(200);
PWM -= 10;
if(PWM < 0){
PWM = 0;
}
analogWrite(PWM_R_Pin,PWM);
analogWrite(PWM_L_Pin,PWM);
}
}
74 changes: 74 additions & 0 deletions Arduino_Exercises/practice12/practice12.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Arduino_Exercises/practice12.ino
*
* Copyright(C) 2020 RT Corporation <support@rt-net.jp>
* All rights reserved.
*
* License: Apache License, Version 2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
*/

int DIR_R_Pin = D12;
int DIR_L_Pin = D0;
int SW1_Pin = D7;
int SW2_Pin = D8;
int PWM_R_Pin = D11;
int PWM_L_Pin = D10;
int CW_R = LOW;
int CCW_R = HIGH;
int CW_L = HIGH;
int CCW_L = LOW;
int BUZZER_Pin = D2;
int LED_Pin = D13;

int PWM =0;

void setup() {
// put your setup code here, to run once:
pinMode(DIR_R_Pin,OUTPUT);
pinMode(DIR_L_Pin,OUTPUT);

pinMode(LED_Pin,OUTPUT);
pinMode(BUZZER_Pin,OUTPUT);

pinMode(SW1_Pin,INPUT_PULLUP);
pinMode(SW2_Pin,INPUT_PULLUP);

digitalWrite(DIR_R_Pin,CW_R);
digitalWrite(DIR_L_Pin,CW_L);

digitalWrite(BUZZER_Pin,HIGH);
}

void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(SW1_Pin) == LOW){
delay(200);
PWM += 10;
if(PWM > 255){
PWM = 255;
digitalWrite(BUZZER_Pin,HIGH);
}
else{
digitalWrite(LED_Pin,LOW);
digitalWrite(BUZZER_Pin,LOW);
}
analogWrite(PWM_R_Pin,PWM);
analogWrite(PWM_L_Pin,PWM);
}
if(digitalRead(SW2_Pin) == LOW){
delay(200);
PWM -= 10;
if(PWM < 0){
PWM = 0;
digitalWrite(LED_Pin,HIGH);
}
else{
digitalWrite(BUZZER_Pin,LOW);
digitalWrite(LED_Pin,LOW);
}
analogWrite(PWM_R_Pin,PWM);
analogWrite(PWM_L_Pin,PWM);
}
}
54 changes: 54 additions & 0 deletions Arduino_Exercises/practice13/practice13.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Arduino_Exercises/practice13.ino
*
* Copyright(C) 2020 RT Corporation <support@rt-net.jp>
* All rights reserved.
*
* License: Apache License, Version 2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
*/

int DIR_R_Pin = D12;
int DIR_L_Pin = D0;
int SW1_Pin = D7;
int SW2_Pin = D8;
int PWM_R_Pin = D11;
int PWM_L_Pin = D10;
int CW_R = 0;
int CCW_R = 1;
int CW_L = 1;
int CCW_L = 0;

int PWM =50;

void setup() {
// put your setup code here, to run once:
pinMode(DIR_R_Pin,OUTPUT);
pinMode(DIR_L_Pin,OUTPUT);

pinMode(SW1_Pin,INPUT_PULLUP);
pinMode(SW2_Pin,INPUT_PULLUP);

digitalWrite(DIR_R_Pin,CW_R);
digitalWrite(DIR_L_Pin,CW_L);

}

void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(SW1_Pin) == LOW){
delay(200);
digitalWrite(DIR_R_Pin,CW_R);
digitalWrite(DIR_L_Pin,CW_L);
analogWrite(PWM_R_Pin,PWM);
analogWrite(PWM_L_Pin,PWM);
}
if(digitalRead(SW2_Pin) == LOW){
delay(200);
digitalWrite(DIR_R_Pin,CCW_R);
digitalWrite(DIR_L_Pin,CCW_L);
analogWrite(PWM_R_Pin,PWM);
analogWrite(PWM_L_Pin,PWM);
}
}
Loading

0 comments on commit 635d30d

Please sign in to comment.