Advertisement
Zeda

Arduino 7-Segment, more optimized

Oct 24th, 2017
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. const char nums[10] = {0x7E,0x48,0xBC,0xB6,0xD2,0xE6,0xEE,0x72,0xFE,0xF6};
  2. void setup() {
  3. for(int i=2;i<10;i++){
  4. pinMode(i, OUTPUT);
  5. digitalWrite(i, LOW);
  6. }
  7. }
  8. void dispnum7segment(int n) {
  9. for(int i=0;i<8;i+=1){
  10. digitalWrite(9-i,bitRead(nums[n],i));
  11. }
  12. }
  13. void loop() {
  14. for(int k=0;k<10;k++){
  15. dispnum7segment(k);
  16. delay(1000);
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement