Changes between Version 7 and Version 8 of wade/embedded/arduino/example/temp


Ignore:
Timestamp:
May 8, 2013, 6:06:24 PM (12 years ago)
Author:
wade
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • wade/embedded/arduino/example/temp

    v7 v8  
    7070
    7171= 程式二:產生「王」字 =
     72{{{
     73/*
     74  Blink
     75  Turns on an LED on for one second, then off for one second, repeatedly.
     76 
     77  This example code is in the public domain.
     78 */
     79
     80void setup() {
     81  // Set Vcc Pin
     82  pinMode(2, OUTPUT);
     83  pinMode(3, OUTPUT);
     84  pinMode(4, OUTPUT);
     85  pinMode(5, OUTPUT); 
     86  pinMode(6, OUTPUT);
     87  pinMode(7, OUTPUT); 
     88  pinMode(8, OUTPUT);
     89  pinMode(9, OUTPUT);
     90  digitalWrite(2, LOW);
     91  digitalWrite(3, LOW);
     92  digitalWrite(4, LOW);
     93  digitalWrite(5, LOW);
     94  digitalWrite(6, LOW);
     95  digitalWrite(7, LOW);
     96  digitalWrite(8, LOW);
     97  digitalWrite(9, LOW);
     98 
     99  // Set GND Pin
     100  pinMode(10, OUTPUT);
     101  pinMode(11, OUTPUT);
     102  pinMode(12, OUTPUT);
     103  pinMode(13, OUTPUT);
     104  pinMode(14, OUTPUT);
     105  pinMode(15, OUTPUT);
     106  pinMode(16, OUTPUT);
     107  pinMode(17, OUTPUT);
     108  digitalWrite(10, HIGH);
     109  digitalWrite(11, HIGH);
     110  digitalWrite(12, HIGH);
     111  digitalWrite(13, HIGH);
     112  digitalWrite(14, HIGH);
     113  digitalWrite(15, HIGH);
     114  digitalWrite(16, HIGH);
     115  digitalWrite(17, HIGH);
     116}
     117
     118void loop() {
     119 
     120  // time 1
     121  digitalWrite(2, HIGH);   // HIGH
     122//  digitalWrite(3, HIGH);   // HIGH
     123//  digitalWrite(4, HIGH);   // HIGH
     124//  digitalWrite(5, HIGH);   // HIGH
     125//  digitalWrite(6, HIGH);   // HIGH
     126//  digitalWrite(7, HIGH);   // HIGH
     127//  digitalWrite(8, HIGH);   // HIGH
     128//  digitalWrite(9, HIGH);   // HIGH
     129  digitalWrite(10, LOW);
     130  digitalWrite(11, LOW);
     131  digitalWrite(12, LOW);
     132  digitalWrite(13, LOW);
     133  digitalWrite(14, LOW);
     134  digitalWrite(15, LOW);
     135  digitalWrite(16, LOW);
     136  digitalWrite(17, LOW);
     137//  delay(300);
     138  clean();
     139 
     140   
     141  // time 2
     142//  digitalWrite(2, HIGH);   // HIGH
     143  digitalWrite(3, HIGH);   // HIGH
     144//  digitalWrite(4, HIGH);   // HIGH
     145//  digitalWrite(5, HIGH);   // HIGH
     146//  digitalWrite(6, HIGH);   // HIGH
     147//  digitalWrite(7, HIGH);   // HIGH
     148//  digitalWrite(8, HIGH);   // HIGH
     149//  digitalWrite(9, HIGH);   // HIGH
     150//  digitalWrite(10, LOW);
     151//  digitalWrite(11, LOW);
     152//  digitalWrite(12, LOW);
     153  digitalWrite(13, LOW);
     154//  digitalWrite(14, LOW);
     155//  digitalWrite(15, LOW);
     156//  digitalWrite(16, LOW);
     157//  digitalWrite(17, LOW);
     158//  delay(300);
     159  clean();
     160
     161
     162  // time 3
     163//  digitalWrite(2, HIGH);   // HIGH
     164//  digitalWrite(3, HIGH);   // HIGH
     165  digitalWrite(4, HIGH);   // HIGH
     166//  digitalWrite(5, HIGH);   // HIGH
     167//  digitalWrite(6, HIGH);   // HIGH
     168//  digitalWrite(7, HIGH);   // HIGH
     169//  digitalWrite(8, HIGH);   // HIGH
     170//  digitalWrite(9, HIGH);   // HIGH
     171//  digitalWrite(10, LOW);
     172//  digitalWrite(11, LOW);
     173//  digitalWrite(12, LOW);
     174  digitalWrite(13, LOW);
     175//  digitalWrite(14, LOW);
     176//  digitalWrite(15, LOW);
     177//  digitalWrite(16, LOW);
     178//  digitalWrite(17, LOW);
     179//  delay(300);
     180  clean();
     181
     182  // time 4
     183//  digitalWrite(2, HIGH);   // HIGH
     184//  digitalWrite(3, HIGH);   // HIGH
     185//  digitalWrite(4, HIGH);   // HIGH
     186  digitalWrite(5, HIGH);   // HIGH
     187//  digitalWrite(6, HIGH);   // HIGH
     188//  digitalWrite(7, HIGH);   // HIGH
     189//  digitalWrite(8, HIGH);   // HIGH
     190//  digitalWrite(10, LOW);
     191//  digitalWrite(11, LOW);
     192//  digitalWrite(12, LOW);
     193  digitalWrite(13, LOW);
     194//  digitalWrite(14, LOW);
     195//  digitalWrite(15, LOW);
     196//  digitalWrite(16, LOW);
     197//  digitalWrite(17, LOW);
     198//  delay(300);
     199  clean();
     200
     201  // time 5
     202//  digitalWrite(2, HIGH);   // HIGH
     203//  digitalWrite(3, HIGH);   // HIGH
     204//  digitalWrite(4, HIGH);   // HIGH
     205//  digitalWrite(5, HIGH);   // HIGH
     206  digitalWrite(6, HIGH);   // HIGH
     207//  digitalWrite(7, HIGH);   // HIGH
     208//  digitalWrite(8, HIGH);   // HIGH
     209  digitalWrite(10, LOW);
     210  digitalWrite(11, LOW);
     211  digitalWrite(12, LOW);
     212  digitalWrite(13, LOW);
     213  digitalWrite(14, LOW);
     214  digitalWrite(15, LOW);
     215  digitalWrite(16, LOW);
     216  digitalWrite(17, LOW);
     217  clean();
     218
     219  // time 6
     220//  digitalWrite(2, HIGH);   // HIGH
     221//  digitalWrite(3, HIGH);   // HIGH
     222//  digitalWrite(4, HIGH);   // HIGH
     223//  digitalWrite(5, HIGH);   // HIGH
     224//  digitalWrite(6, HIGH);   // HIGH
     225  digitalWrite(7, HIGH);   // HIGH
     226//  digitalWrite(8, HIGH);   // HIGH
     227//  digitalWrite(10, LOW);
     228//  digitalWrite(11, LOW);
     229//  digitalWrite(12, LOW);
     230  digitalWrite(13, LOW);
     231//  digitalWrite(14, LOW);
     232//  digitalWrite(15, LOW);
     233//  digitalWrite(16, LOW);
     234//  digitalWrite(17, LOW);
     235//  delay(300);
     236  clean();
     237// 
     238//  // time 7
     239//  digitalWrite(2, HIGH);   // HIGH
     240//  digitalWrite(3, HIGH);   // HIGH
     241//  digitalWrite(4, HIGH);   // HIGH
     242//  digitalWrite(5, HIGH);   // HIGH
     243//  digitalWrite(6, HIGH);   // HIGH
     244//  digitalWrite(7, HIGH);   // HIGH
     245  digitalWrite(8, HIGH);   // HIGH
     246//    digitalWrite(9, HIGH);   // HIGH
     247//  digitalWrite(10, LOW);
     248//  digitalWrite(11, LOW);
     249//  digitalWrite(12, LOW);
     250  digitalWrite(13, LOW);
     251//  digitalWrite(14, LOW);
     252//  digitalWrite(15, LOW);
     253//  digitalWrite(16, LOW);
     254//  digitalWrite(17, LOW);
     255//  delay(300);
     256  clean();
     257// 
     258
     259  // time 8
     260//  digitalWrite(2, HIGH);   // HIGH
     261//  digitalWrite(3, HIGH);   // HIGH
     262//  digitalWrite(4, HIGH);   // HIGH
     263//  digitalWrite(5, HIGH);   // HIGH
     264//  digitalWrite(6, HIGH);   // HIGH
     265//  digitalWrite(7, HIGH);   // HIGH
     266//  digitalWrite(8, HIGH);   // HIGH
     267  digitalWrite(9, HIGH);   // HIGH
     268  digitalWrite(10, LOW);
     269  digitalWrite(11, LOW);
     270  digitalWrite(12, LOW);
     271  digitalWrite(13, LOW);
     272  digitalWrite(14, LOW);
     273  digitalWrite(15, LOW);
     274  digitalWrite(16, LOW);
     275  digitalWrite(17, LOW);
     276  clean();
     277}
     278
     279void clean()
     280{
     281  delay(300);
     282  digitalWrite(2, LOW);
     283  digitalWrite(3, LOW);
     284  digitalWrite(4, LOW);
     285  digitalWrite(5, LOW);
     286  digitalWrite(6, LOW);
     287  digitalWrite(7, LOW);
     288  digitalWrite(8, LOW);
     289  digitalWrite(9, LOW);
     290 
     291  digitalWrite(10, HIGH);
     292  digitalWrite(11, HIGH);
     293  digitalWrite(12, HIGH);
     294  digitalWrite(13, HIGH);
     295  digitalWrite(14, HIGH);
     296  digitalWrite(15, HIGH);
     297  digitalWrite(16, HIGH);
     298  digitalWrite(17, HIGH);
     299}
     300}}}