Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Courses
csci206_lecture_examples
Commits
e63dac72
Commit
e63dac72
authored
Jan 24, 2014
by
Alan Marchiori
Browse files
added change ardiuno code
parent
a0b7b2e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
section01/Lec04/Lec04 - PH1_1 - 1_3.odp
deleted
100644 → 0
View file @
a0b7b2e4
File deleted
section01/Lec05/change_lcd/change_lcd.ino
0 → 100644
View file @
e63dac72
#include <LiquidCrystal.h>
#include <stdio.h>
LiquidCrystal
lcd
(
8
,
9
,
4
,
5
,
6
,
7
);
struct
change
{
int
quarters
;
int
dimes
;
int
nickels
;
int
pennies
;
};
struct
change
*
make_change
(
float
amount
)
{
int
cents
=
amount
*
100
;
struct
change
*
c
=
(
struct
change
*
)
malloc
(
sizeof
(
*
c
));
c
->
quarters
=
0
;
c
->
dimes
=
0
;
c
->
nickels
=
0
;
c
->
pennies
=
0
;
while
(
cents
>
0
){
if
(
cents
>=
25
)
{
c
->
quarters
++
;
cents
-=
25
;
}
else
if
(
cents
>=
10
)
{
c
->
dimes
++
;
cents
-=
10
;
}
else
if
(
cents
>=
5
)
{
c
->
nickels
++
;
cents
-=
5
;
}
else
{
c
->
pennies
=
cents
;
cents
=
0
;
}
}
return
c
;
}
void
sprint_change
(
char
*
line1
,
char
*
line2
,
struct
change
*
c
)
{
sprintf
(
line1
,
"%3d qtr, %d dme"
,
c
->
quarters
,
c
->
dimes
);
sprintf
(
line2
,
"%3d nkl, %d pny"
,
c
->
nickels
,
c
->
pennies
);
}
void
setup
()
{
lcd
.
begin
(
16
,
2
);
lcd
.
setCursor
(
0
,
0
);
}
void
loop
()
{
static
float
amount
=
0.0
;
char
line1
[
30
],
line2
[
30
];
struct
change
*
c
=
make_change
(
amount
);
amount
+=
0.01
;
sprint_change
(
line1
,
line2
,
c
);
lcd
.
clear
();
lcd
.
setCursor
(
0
,
0
);
lcd
.
write
(
line1
);
lcd
.
setCursor
(
0
,
1
);
lcd
.
write
(
line2
);
free
(
c
);
delay
(
500
);
}
section01/Lec05/hello_lcd_c/hello_lcd_c.ino
deleted
100644 → 0
View file @
a0b7b2e4
#include <LiquidCrystal.h>
#include <stdio.h>
static
FILE
uartout
=
{
0
};
LiquidCrystal
lcd
(
8
,
9
,
4
,
5
,
6
,
7
);
static
int
uart_putchar
(
char
c
,
FILE
*
stream
)
{
Serial
.
write
(
c
);
return
0
;
}
void
setup
()
{
// put your setup code here, to run once:
Serial
.
begin
(
9600
);
fdev_setup_stream
(
&
uartout
,
uart_putchar
,
NULL
,
_FDEV_SETUP_WRITE
);
stdout
=
&
uartout
;
printf
(
"startup
\n
"
);
lcd
.
begin
(
16
,
2
);
lcd
.
setCursor
(
0
,
0
);
lcd
.
write
(
"hello"
);
}
void
loop
()
{
// put your main code here, to run repeatedly:
printf
(
"hello
\n
"
);
delay
(
500
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment