Skip to content

Commit dbbfd0e

Browse files
committed
migrated repos to one single common repo
0 parents  commit dbbfd0e

File tree

51 files changed

+6873
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+6873
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#include <Stepper.h>
2+
#include <Servo.h>
3+
Servo s1;
4+
Servo s2;
5+
Servo s3;
6+
Servo s4;
7+
int stepIN1Pin = 2;
8+
int stepIN2Pin = 3;
9+
int stepIN3Pin = 4;
10+
int stepIN4Pin = 5;
11+
int stepsPerRevolution = 2048;
12+
Stepper myStepper(stepsPerRevolution, stepIN1Pin, stepIN3Pin, stepIN2Pin, stepIN4Pin);
13+
14+
int joyX=0;
15+
int joyY=1;
16+
int joyVal;
17+
int joyX2=2;
18+
int joyY2=3;
19+
int joyVal2;
20+
int b1=18;
21+
int b2=19;
22+
23+
24+
void setup ()
25+
{
26+
s1.attach(6);
27+
s2.attach(7);
28+
s3.attach(8);
29+
s4.attach(9);
30+
myStepper.setSpeed(15);
31+
pinMode (b1,INPUT);
32+
pinMode (b2,INPUT);
33+
digitalWrite (b1,HIGH);
34+
digitalWrite (b2,HIGH);
35+
}
36+
void loop (){
37+
joyVal = analogRead (joyX);
38+
joyVal = map (joyVal, 0, 1023, 0, 180);
39+
s1.write (joyVal);
40+
41+
42+
joyVal = analogRead (joyY);
43+
joyVal = map (joyVal, 0, 1023, 0, 180);
44+
s2.write (joyVal);
45+
delay(15);
46+
47+
joyVal2 = analogRead (joyX2);
48+
joyVal2 = map (joyVal2, 0, 1023, 0, 180);
49+
s3.write (joyVal2);
50+
51+
52+
joyVal2 = analogRead (joyY2);
53+
joyVal2 = map (joyVal2, 0, 1023, 0, 180);
54+
s4.write (joyVal2);
55+
delay(15);
56+
57+
58+
59+
60+
61+
62+
63+
64+
///////////////////////////////////////////////////////////////////////
65+
int button1State, button2State;
66+
button1State = digitalRead(b1);
67+
button2State = digitalRead(b2);
68+
if (((button1State == LOW) && !(button2State == LOW))) // if we're pushing button 1 OR button 2
69+
myStepper.step(stepsPerRevolution/15);
70+
if (((button2State == LOW) && !(button1State == LOW))) // if we're pushing button 1 OR button 2
71+
myStepper.step(-stepsPerRevolution/15);
72+
//////////////////////////////////////////////////////////////////////////
73+
}
74+
75+
76+
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#include <Stepper.h>
2+
#include <Servo.h>
3+
Servo s1;
4+
Servo s2;
5+
Servo s3;
6+
Servo s4;
7+
int stepIN1Pin = 2;
8+
int stepIN2Pin = 3;
9+
int stepIN3Pin = 4;
10+
int stepIN4Pin = 5;
11+
int stepsPerRevolution = 2048;
12+
Stepper myStepper(stepsPerRevolution, stepIN1Pin, stepIN3Pin, stepIN2Pin, stepIN4Pin);
13+
14+
int joyX=0;
15+
int joyY=1;
16+
int joyVal;
17+
int joyX2=2;
18+
int joyY2=3;
19+
int joyVal2;
20+
int b1=18;
21+
int b2=19;
22+
int joyVal3;
23+
int joyVal4;
24+
int hand;
25+
int rotate;
26+
int body;
27+
//????????????????????????
28+
boolean lastB=LOW;
29+
boolean curB=LOW;
30+
boolean s3On=false;
31+
//????????????????????????
32+
33+
void setup ()
34+
{Serial.begin(9600);
35+
s1.attach(6);
36+
s2.attach(7);
37+
s3.attach(8);
38+
s4.attach(9);
39+
myStepper.setSpeed(15);
40+
pinMode (b1,INPUT);
41+
pinMode (b2,INPUT);
42+
digitalWrite (b1,HIGH);
43+
digitalWrite (b2,HIGH);
44+
hand=88;
45+
rotate=88;
46+
body=88;
47+
}
48+
49+
////////////////////////////////////
50+
boolean debounce(boolean last)
51+
{
52+
boolean cur=digitalRead (b1);
53+
if (last!=cur);
54+
{
55+
delay(5);
56+
cur=digitalRead (b1);
57+
}
58+
return cur;}
59+
//////////////////////////////////
60+
61+
62+
63+
64+
void loop (){
65+
66+
67+
/////////////////////////////////////
68+
curB=debounce(lastB);
69+
70+
if (lastB==LOW && curB ==HIGH)
71+
72+
{s3On=!s3On;
73+
74+
}
75+
76+
lastB= curB;
77+
if (s3On==HIGH){
78+
s3.write(180);}else{s3.write(0);};
79+
////////////////////////////////////////////
80+
81+
82+
83+
joyVal = analogRead (joyX);
84+
joyVal = map (joyVal, 0, 1023, 0, 180);
85+
if (joyVal>120) {body=body+5;}
86+
if (joyVal<50) {body=body-5;}
87+
body=constrain(body,0,180);
88+
//rotate = map (rotate, 88, 180, 88, 180);
89+
s2.write (body);
90+
91+
92+
93+
joyVal2 = analogRead (joyY);
94+
joyVal2 = map (joyVal2, 0, 1023, 0, 180);
95+
delay(10);
96+
97+
joyVal3 = analogRead (joyX2);
98+
joyVal3 = map (joyVal3, 0, 1023, 0, 180);
99+
if (joyVal3>120){hand=hand+5;}
100+
if (joyVal3<50){hand=hand-5;}
101+
hand=constrain(hand,0,180);
102+
/*if (joyVal3>179){hand=hand+20;}
103+
if (joyVal3<10){hand=hand-20;}*/
104+
s1.write (hand);
105+
106+
107+
joyVal4 = analogRead (joyY2);
108+
joyVal4 = map (joyVal4, 0, 1023, 0, 180);
109+
if (joyVal4>120) {rotate=rotate+5;}
110+
if (joyVal4<50) {rotate=rotate-5;}
111+
rotate=constrain(rotate,0,180);
112+
//rotate = map (rotate, 88, 180, 88, 180);
113+
s4.write (rotate);
114+
delay(10);
115+
116+
117+
118+
///////////////////////////////////////////////////////////////////////
119+
120+
if (joyVal2>150) // if we're pushing button 1 OR button 2
121+
myStepper.step(stepsPerRevolution/15);
122+
if (joyVal2<30) // if we're pushing button 1 OR button 2
123+
myStepper.step(-stepsPerRevolution/15);
124+
//////////////////////////////////////////////////////////////////////////
125+
126+
}
127+
128+
129+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#include <Ultrasonic.h>
2+
#include <LiquidCrystal_I2C.h>
3+
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
4+
5+
byte per[8] =
6+
{
7+
0b00100,
8+
0b00000,
9+
0b01110,
10+
0b10101,
11+
0b00100,
12+
0b01010,
13+
0b10001,
14+
0b00000
15+
};
16+
byte arr[8] =
17+
{
18+
0b00100,
19+
0b01110,
20+
0b11111,
21+
0b00100,
22+
0b00100,
23+
0b00100,
24+
0b00000,
25+
0b00000
26+
};
27+
28+
29+
30+
Ultrasonic ultrasonic(A0,A1);
31+
int Height;
32+
33+
void setup() {
34+
35+
pinMode (17,OUTPUT);
36+
pinMode (16,OUTPUT);
37+
digitalWrite (17,HIGH);
38+
digitalWrite (16,HIGH);
39+
40+
41+
lcd.begin(16, 2);
42+
lcd.createChar(1, per);
43+
lcd.createChar(2, arr);
44+
lcd.setBacklight(0x1);
45+
}
46+
47+
void loop()
48+
{
49+
lcd.clear();
50+
//lcd.print("Distance: ");
51+
//lcd.print(ultrasonic.Ranging(CM));
52+
//lcd.print("cm");
53+
//lcd.setCursor(0, 1);
54+
lcd.print("Sizin boyunyz: ");
55+
lcd.setCursor (4,1);
56+
lcd.write (1);
57+
lcd.write (2);
58+
59+
lcd.setCursor (7,1);
60+
Height=200-(ultrasonic.Ranging(CM));
61+
lcd.print(Height);
62+
lcd.print("cm");
63+
64+
65+
delay(1000);
66+
}
67+
68+
69+
70+

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# ultrasonic-projects
2+
Project sources of Arduino and RaspberryPi using the Adafruit Ultrasonic sensor
3+
## contains:
4+
> Height measurer project with LCD and Ultrasonic sensor
5+
--------------------
6+
> The sonar using distance processing to change the buzzer sound and vibration frequency
7+
--------------------
8+
> Screen dimming and turning on when motion presents using Ultrasonic senor and RaspberryPi (Python)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#include <Servo.h>
2+
Servo s1;
3+
Servo s2;
4+
Servo s3;
5+
Servo s4;
6+
Servo s5;
7+
int const p1 = A1;
8+
int const p2 = A2;
9+
int const p3 = A3;
10+
int const p4 = A4;
11+
int const p5 = A5;
12+
int val1;
13+
int val2;
14+
int val3;
15+
int val4;
16+
int val5;
17+
int angle1;
18+
int angle2;
19+
int angle3;
20+
int angle4;
21+
int angle5;
22+
23+
void setup() {
24+
Serial.begin(9600);
25+
s1.attach(2);
26+
s2.attach(3);
27+
s3.attach(4);
28+
s4.attach(5);
29+
s5.attach(6);
30+
}
31+
32+
void loop() {
33+
val1 = analogRead(p1);
34+
val2 = analogRead(p2);
35+
val3 = analogRead(p3);
36+
val4 = analogRead(p4);
37+
val5 = analogRead(p5);
38+
angle1 = map(val1, 0, 1023, 0, 179);
39+
angle2 = map(val2, 0, 1023, 0, 179);
40+
angle3 = map(val3, 0, 1023, 0, 179);
41+
angle4 = map(val4, 0, 1023, 0, 179);
42+
//angle5 = map(val5, 0, 1023, 0, 179);
43+
Serial.print (val1);
44+
Serial.print (" ");
45+
Serial.print (angle1);
46+
Serial.print (" ");
47+
Serial.println (angle2);
48+
/*Serial.print (" ");
49+
Serial.print (angle1);
50+
Serial.print (" ");
51+
Serial.print (angle1);
52+
Serial.print (" ");*/
53+
54+
s1.write(angle1);
55+
56+
s2.write(angle2);
57+
58+
s3.write(angle3);
59+
//delay (15);
60+
s4.write(angle4);
61+
//delay (15);
62+
s5.write(angle5);
63+
// delay (15);*/
64+
}

0 commit comments

Comments
 (0)