-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaking.Rmd
263 lines (205 loc) · 4.42 KB
/
making.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
---
title: "메이킹"
description: |
설계도를 기반으로 3D 프린터 제작과 코딩을 통해 가빈을 제작해 나간다.
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
# https://github.com/rstudio/distill/issues/11
xaringanExtra::use_panelset()
xaringanExtra::style_panelset_tabs(
foreground = "#F7F7F7",
background = "#1E61B0",
active_foreground = "#F7F7F7", # R logo 회색
active_background = "#1E61B0", # R logo 파란색
active_border_color = "#1E61B0",
hover_foreground = "#F7F7F7",
hover_background = "#1E6190",
hover_border_color = "#1E6190",
inactive_opacity = 0.5
)
```
# 기구물 3D 프린터
# 태양열 발전
::: {.l-page}
::: {.panelset}
::: {.panel}
## ::: 이미지 ::: {.panel-name}
![](fig/production/solar.jpeg){width="437"}
:::
::: {.panel}
## ::: 코드 ::: {.panel-name}
```{r solar-code, eval = FALSE, echo = TRUE}
#include <SoftwareSerial.h>
int solar_input = A0; // 태양광 패널 인풋
void setup() {
Serial.begin(9600);
pinMode(solar_input, INPUT); // 태양광 전류 인풋
}
void loop() {
int solar_value;
solar_value = analogRead(solar_input);
delay(1000);
Serial.print(" salor panel = ");
Serial.print(solar_value);
Serial.print("\n");
}
```
:::
:::
:::
# 디지털 디스플레이
::: {.l-page}
::: {.panelset}
::: {.panel}
## ::: 이미지 ::: {.panel-name}
![](fig/production/display.jpeg){width="437"}
:::
::: {.panel}
## ::: 코드 ::: {.panel-name}
- 참고: [4 Bits Digital Tube LED Display Module library](https://forum.arduino.cc/t/4-bits-digital-tube-led-display-module-library/375305)
```{r display-code, eval = FALSE, echo = TRUE}
unsigned char LED_0F[] =
{// 0 1 2 3 4 5 6 7 8 9 A b C d E F -
0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x8C,0xBF,0xC6,0xA1,0x86,0xFF,0xbf
};
unsigned char LED[4]; //用于LED的4位显示缓存
int SCLK = 2;
int RCLK = 1;
int DIO = 0; //这里定义了那三个脚
void setup ()
{
pinMode(SCLK,OUTPUT);
pinMode(RCLK,OUTPUT);
pinMode(DIO,OUTPUT); //让三个脚都是输出状态
}
void loop()
{
LED[0]=1;
LED[1]=2;
LED[2]=3;
LED[3]=4;
while(1)
{
LED4_Display ();
}
}
```
:::
:::
:::
# 아두이노 코드
```{r show-code, eval = FALSE, echo=TRUE}
#include<SoftwareSerial.h>
int fan = 9;
int x = A0; // 태양광 패널 인풋
int a;
int b;
int c;
int d;
unsigned char LED_0F[] =
{// 0 1 2 3 4 5 6 7 8 9 A b C d E F -
0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x8C,0xBF,0xC6,0xA1,0x86,0xFF,0xbf
};
unsigned char LED[4]; //用于LED的4位显示缓存
int SCLK = 2;
int RCLK = 1;
int DIO = 0; //这里定义了那三个脚
void setup ()
{
Serial.begin(9600);
pinMode(fan, OUTPUT);
pinMode(x, INPUT); // 태양광 전류 인풋
pinMode(SCLK,OUTPUT);
pinMode(RCLK,OUTPUT);
pinMode(DIO,OUTPUT); //让三个脚都是输出状态
}
void loop()
{
int x;
int a;
int b;
int c;
int d;
a=floor(x);
b=floor(x/10);
c=floor(x/100);
d=floor(x/1000);
b=b%10;
b=analogRead(b);
delay(1);
Serial.print(" a = ");
Serial.print(a);
x = analogRead(x);
delay(1);
Serial.print(" salor panel = ");
Serial.print(x);
a = analogRead(a);
delay(1);
Serial.print(" a = ");
Serial.print(b);
digitalWrite(fan, HIGH);
delay(1); // fan 100초 동안 가동
LED[0]=a%10;
LED[1]=b%10;
LED[2]=c%10;
LED[3]=d%10;
while(1)
{
LED4_Display ();
}
}
void LED4_Display (void)
{
unsigned char *led_table; // 查表指针
unsigned char i;
//显示第1位
led_table = LED_0F + LED[0];
i = *led_table;
LED_OUT(i);
LED_OUT(0x01);
digitalWrite(RCLK,LOW);
digitalWrite(RCLK,HIGH);
//显示第2位
led_table = LED_0F + LED[1];
i = *led_table;
LED_OUT(i);
LED_OUT(0x02);
digitalWrite(RCLK,LOW);
digitalWrite(RCLK,HIGH);
//显示第3位
led_table = LED_0F + LED[2];
i = *led_table;
LED_OUT(i);
LED_OUT(0x04);
digitalWrite(RCLK,LOW);
digitalWrite(RCLK,HIGH);
//显示第4位
led_table = LED_0F + LED[3];
i = *led_table;
LED_OUT(i);
LED_OUT(0x08);
digitalWrite(RCLK,LOW);
digitalWrite(RCLK,HIGH);
}
void LED_OUT(unsigned char X)
{
unsigned char i;
for(i=8;i>=1;i--)
{
if (X&0x80)
{
digitalWrite(DIO,HIGH);
}
else
{
digitalWrite(DIO,LOW);
}
X<<=1;
digitalWrite(SCLK,LOW);
digitalWrite(SCLK,HIGH);
}
}
```