XuanTao_2453143
XuanTao_2453143
XuanTao_2453143
// C++ code
//
void setup()
pinMode (0 , OUTPUT ) ;
pinMode (1 , OUTPUT ) ;
void loop()
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
delay(2000);
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
4.2
void setup(){
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
void loop(){
digitalWrite(1, HIGH);
digitalWrite(3, HIGH);
digitalWrite(5, HIGH);
digitalWrite(7, HIGH);
digitalWrite(2, LOW);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(8, LOW);
delay(1000);
digitalWrite(1, LOW);
digitalWrite(3, LOW);
digitalWrite(5, LOW);
digitalWrite(7, LOW);
digitalWrite(2, HIGH);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(8, HIGH);
delay(1000);
digitalWrite(1, LOW);
digitalWrite(3, HIGH);
digitalWrite(5, LOW);
digitalWrite(7, HIGH);
digitalWrite(2, HIGH);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(8, HIGH);
delay(1000);
digitalWrite(1, LOW);
digitalWrite(3, LOW);
digitalWrite(5, LOW);
digitalWrite(7, HIGH);
digitalWrite(2, HIGH);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(8, LOW);
delay(1000);
digitalWrite(1, LOW);
digitalWrite(3, HIGH);
digitalWrite(5, HIGH);
digitalWrite(7, LOW);
digitalWrite(2, HIGH);
digitalWrite(4, LOW);
digitalWrite(6, HIGH);
digitalWrite(8, HIGH);
delay(1000);
digitalWrite(1, HIGH);
digitalWrite(3, HIGH);
digitalWrite(5, LOW);
digitalWrite(7, HIGH);
digitalWrite(2, LOW);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(8, LOW);
delay(1000);
digitalWrite(1, LOW);
digitalWrite(3, LOW);
digitalWrite(5, LOW);
digitalWrite(7, HIGH);
digitalWrite(2, LOW);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(8, HIGH);
delay(1000);
digitalWrite(1, HIGH);
digitalWrite(3, LOW);
digitalWrite(5, HIGH);
digitalWrite(7, LOW);
digitalWrite(2, HIGH);
digitalWrite(4, LOW);
digitalWrite(6, HIGH);
digitalWrite(8, HIGH);
delay(1000);
digitalWrite(1, LOW);
digitalWrite(3, HIGH);
digitalWrite(5, HIGH);
digitalWrite(7, HIGH);
digitalWrite(2, LOW);
digitalWrite(4, HIGH);
digitalWrite(6, LOW);
digitalWrite(8, HIGH);
delay(1000);
digitalWrite(1, LOW);
digitalWrite(3, LOW);
digitalWrite(5, LOW);
digitalWrite(7, HIGH);
digitalWrite(2, LOW);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(8, LOW);
delay(1000);
4.3
void setup(){
if (i == 0){
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
void loop(){
displayNumber(0);
delay(1000);
delay(1000);
4.4
// C++ code
//
void setup()
pinMode(i, OUTPUT);
if (j == 0){
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
if (i == 0){
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, LOW);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
void loop()
displayNumber1(j);
displayNumber2(i);
delay(1000);
displayNumber1(20);
displayNumber2(0);
delay(1000);
4.5
void setup(){
pinMode(i, OUTPUT);
}
void displayNumber(int i){
if (i == 0){
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
}
}
void loop(){
digitalWrite(9,LOW);
digitalWrite(8, HIGH);
displayNumber(i);
delay(1000);}
delay(500);
digitalWrite(8, LOW);
digitalWrite(10, HIGH);
for(int i = 2; i >=0;i--){
displayNumber(i);
delay(1000);}
delay(500);
digitalWrite(10, LOW);
digitalWrite(9, HIGH);
displayNumber(i);
delay(1000);}
delay(500);
4.6, 4.7
void setup(){
pinMode(i, OUTPUT);
}
if (i == 0){
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
void loop(){
digitalWrite(8, HIGH);
digitalWrite(13, HIGH);
displayNumber(i);
delay(1000);
if(i == 2){
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
}}
digitalWrite(8, LOW);
digitalWrite(12, LOW);
delay(1000);
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
displayNumber(i);
delay(1000);
if(i == 3){
digitalWrite(10, LOW);
digitalWrite(9, HIGH);
}}
digitalWrite(11, LOW);
digitalWrite(9, LOW);
4.8
int second = 0;
int minute = 0;
int hour = 0;
void setup()
pinMode(i, OUTPUT);
digitalWrite(num-1, HIGH);
void clearClock(){
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
void loop()
displayOnClock(i + 1);
delay(1000);
clearClock();
delay(1000);
clearClock();
4.9
int second = 0;
int minute = 0;
int hour = 0;
void setup()
pinMode(i, OUTPUT);
digitalWrite(num-1, HIGH);
void clearClock(){
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
void loop()
displayOnClock(12);
delay(500);
clearClock();
displayOnClock(1);
delay(500);
clearClock();
4.10
int second = 0;
int minute = 0;
int hour = 0;
void setup()
pinMode(i, OUTPUT);
if(num <= 12 ){
digitalWrite(num-1, HIGH);
void clearClock(){
digitalWrite(i, LOW);
void loop()
minute=second/60;
hour=minute/60;
int minCount=minute/5-hour*12;
if (secCount == 0 ){secCount=12;}
if (minCount == 0 ){minCount=12;}
if (hourCount == 0 ){hourCount=12;}
clearClock();
displayOnClock(secCount);
displayOnClock(minCount);
displayOnClock(hourCount);
delay(1000);
second +=1;