SM ül 4




#include <Stepper.h> // include stepper library
int revolution = 2038; // the number of steps in one revolution of your motor (28BYJ-48)
Stepper stepper(revolution, 8, 10, 9, 11); // the correct stepping order for your motor (28BYJ-48)

void setup() { // set driver pins as OUTPUT
pinMode(8, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(11, OUTPUT);

// Begin Serial communication at a baud rate of 9600:
Serial.begin(9600);
}

void loop() {
Serial.println(“pp kiirusega 10 rpm”);
stepper.setSpeed(10); // 18 = max working speed for this motor. 10 is max recommended speed
stepper.step(revolution); // move motor one revolution anti-clockwise (2038 steps)
halt(); // call ‘halt()’ function to write motor pins LOW
Serial.println(“ootab 3 sekundit”);
delay(3000); // wait one second (optional)

Serial.println(“vp kiirusega 5 rpm”);
stepper.setSpeed(5); // set speed to 5
stepper.step(-revolution); // move motor one revolution clockwise (-2038 steps)
halt();
Serial.println(“ootab 5 sekundit”);
delay(5000);

}

void halt() { // This writes all motor pins LOW, preventing the motor from drawing current when idle.
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
}

SM ül 3 ja 3A

/* Example sketch to control a 28BYJ-48 stepper motor with ULN2003 driver board and Arduino UNO. More info: https://www.makerguides.com */

// Include the Arduino Stepper.h library:
#include <Stepper.h>

// Define number of steps per rotation:
const int stepsPerRevolution = 2048;

// Wiring:
// Pin 8 to IN1 on the ULN2003 driver
// Pin 9 to IN2 on the ULN2003 driver
// Pin 10 to IN3 on the ULN2003 driver
// Pin 11 to IN4 on the ULN2003 driver

// Create stepper object called 'myStepper', note the pin order:
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);

void setup() {
  // Set the speed to 5 rpm:
  myStepper.setSpeed(5);
  
  // Begin Serial communication at a baud rate of 9600:
  Serial.begin(9600);
}

void loop() {
  // Step one revolution in one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);
  
  // Step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500);
}
/* Example sketch to control a 28BYJ-48 stepper motor with ULN2003 driver board and Arduino UNO. More info: https://www.makerguides.com */

// Include the Arduino Stepper.h library:
#include <Stepper.h>

// Define number of steps per rotation:
const int stepsPerRevolution = 2048;

// Wiring:
// Pin 8 to IN1 on the ULN2003 driver
// Pin 9 to IN2 on the ULN2003 driver
// Pin 10 to IN3 on the ULN2003 driver
// Pin 11 to IN4 on the ULN2003 driver

// Create stepper object called 'myStepper', note the pin order:
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);

void setup() {
  // Set the speed to 5  or 10 rpm:
  myStepper.setSpeed(10);
  
  // Begin Serial communication at a baud rate of 9600:
  Serial.begin(9600);
}

void loop() {
  // Step one revolution in one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);
  
   // Step one revolution in one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);
  
  // Step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(500);
}

SM ül 2

#define A 8
#define B 9
#define C 10
#define D 11
 
#define NUMBER_OF_STEPS_PER_REV 512

void setup(){
pinMode(A,OUTPUT);
pinMode(B,OUTPUT);
pinMode(C,OUTPUT);
pinMode(D,OUTPUT);
}

void write(int a,int b,int c,int d){
digitalWrite(A,a);
digitalWrite(B,b);
digitalWrite(C,c);
digitalWrite(D,d);
}

void onestep(){
write(1,0,0,0);
delay(5);
write(1,1,0,0);
delay(5);
write(0,1,0,0);
delay(5);
write(0,1,1,0);
delay(5);
write(0,0,1,0);
delay(5);
write(0,0,1,1);
delay(5);
write(0,0,0,1);
delay(5);
write(1,0,0,1);
delay(5);
}

void loop(){
int i;
i=0;
while(i<NUMBER_OF_STEPS_PER_REV){
onestep();
i++;
}
}

SM ül 1

//Includes the Arduino Stepper Library
#include <Stepper.h>

// Defines the number of steps per rotation
const int stepsPerRevolution = 2038;

// Creates an instance of stepper class
// Pins entered in sequence IN1-IN3-IN2-IN4 for proper step sequence
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);

void setup() {
	// Nothing to do (Stepper Library sets pins as outputs)
}

void loop() {
	// Rotate CW slowly at 5 RPM
	myStepper.setSpeed(5);
	myStepper.step(stepsPerRevolution);
	delay(1000);
	
	// Rotate CCW quickly at 10 RPM
	myStepper.setSpeed(10);
	myStepper.step(-stepsPerRevolution);
	delay(1000);
}

Servo ül 3

#include <Servo.h>

Servo servo;

void setup(){
servo.attach(9);
}
void loop(){
servo.write(10);
delay(300);
servo.write(0);
delay(300);
servo.write(20);
delay(300);
servo.write(0);
delay(300);
servo.write(30);
delay(300);
servo.write(0);
delay(300);
servo.write(40);
delay(300);
servo.write(0);
delay(300);
servo.write(50);
delay(300);
servo.write(0);
delay(300);
servo.write(60);
delay(300);
servo.write(0);
delay(300);
servo.write(70);
delay(300);
servo.write(0);
delay(300);
servo.write(80);
delay(300);
servo.write(0);
delay(300);
servo.write(90);
delay(300);
servo.write(0);
delay(300);
servo.write(100);
delay(300);
servo.write(0);
delay(1000);
servo.write(0);
delay(2000);

}

Servo ül 2

#include <Servo.h>

Servo servo;

void setup() {
servo.attach(9);

}
void loop() {
for(int i=0;i<180; i++){

servo.write(i);

delay(15);

}

for(int i=180; i>0; i–){
servo.write(i);
delay(7);
}

}

Servo ül 1

#include <Servo.h>

Servo servo;

void setup() {
servo.attach(9);

}
void loop() {
servo.write(0);
delay(500);

servo.write(90);
delay(500);

servo.write(180);
delay(500);

servo.write(90);
delay(500);

servo.write(0);
delay(500);

}

Laser variant 2

const char* MorseTable[] = {
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
// space, !, “, #, $, %, &, ‘
NULL, “-.-.–“, “.-..-.”, NULL, NULL, NULL, NULL, “.—-.”,
// ( ) * + , – . /
“-.–.”, “-.–.-“, NULL, “.-.-.”, “–..–“, “-….-“, “.-.-.-“, “-..-.”,
// 0 1 2 3 4 5 6 7
“—–“, “.—-“, “..—“, “…–“, “….-“, “…..”, “-….”, “–…”,
// 8 9 : ; < = > ?
“—..”, “—-.”, “—…”, “-.-.-.”, NULL, “-…-“, NULL, “..–..”,
// @ A B C D E F G
“.–.-.”, “.-“, “-…”, “-.-.”, “-..”, “.”, “..-.”, “–.”,
// H I J K L M N O
“….”, “..”, “.—“, “-.-“, “.-..”, “–“, “-.”, “—“,
// P Q R S T U V W
“.–.”, “–.-“, “.-.”, “…”, “-“, “..-“, “…-“, “.–“,
// X Y Z [ \ ] ^ _
“-..-“, “-.–“, “–..”, NULL, NULL, NULL, NULL, “..–.-“,
// ‘ a b c d e f g
NULL, “.-“, “-…”, “-.-.”, “-..”, “.”, “..-.”, “–.”,
// h i j k l m n o
“….”, “..”, “.—“, “-.-“, “.-..”, “–“, “-.”, “—“,
// p q r s t u v w
“.–.”, “–.-“, “.-.”, “…”, “-“, “..-“, “…-“, “.–“,
// x y z { | } ~ DEL
“-..-“, “-.–“, “–..”, NULL, NULL, NULL, NULL, NULL,
};

int dotLength = 500;
int dashLength = dotLength*3;

void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT);
Serial.begin(9600);
}

void loop() {
char ch;
if(Serial.available()){
ch = Serial.read();
flashDashDot(MorseTable[ch]);
delay(dotLength*2);
}
}

void flashDashDot(const char * morseCode)
{
int i = 0;
while(morseCode[i] != 0)
{
if(morseCode[i] == ‘.’){
dot();
} else if (morseCode[i] == ‘-‘){
dash();
}
i++;
}
}

void dot()
{
digitalWrite(13, HIGH);
delay(dotLength);
digitalWrite(13, LOW);
delay(dotLength);
}

void dash()
{
digitalWrite(13, HIGH);
delay(dashLength);
digitalWrite(13, LOW);
delay(dotLength);
}