Advertisement
gihanchanaka

Untitled

Aug 31st, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. function [ output_args ] = displayTwoDigitsFor( arduinoBoardName,number,ssd1,ssd1Ground,ssd2,ssd2Ground,cycles )
  2. digitOne=floor(number/10);
  3. digitTwo=mod(number,10);
  4. for c=1:cycles
  5.  
  6. displayNumber(arduinoBoardName,ssd1,digitOne);
  7. onSSD(arduinoBoardName,ssd1Ground);
  8. offSSD(arduinoBoardName,ssd1Ground);
  9.  
  10. displayNumber(arduinoBoardName,ssd2,digitTwo);
  11. onSSD(arduinoBoardName,ssd2Ground);
  12. offSSD(arduinoBoardName,ssd2Ground);
  13. end
  14. end
  15.  
  16. function [ output_args ] = displayFourDigitsFor( arduinoBoardName,number,ssd1,ssd1Ground,ssd2,ssd2Ground,ssd3,ssd3Ground,ssd4,ssd4Ground,cycles )
  17. digitOne=floor(number/1000);
  18. digitTwo=mod(floor(number/100),10);
  19. digitThree=mod(floor(number/10),10);
  20. digitFour=mod(number,10);
  21. for c=1:cycles
  22.  
  23. displayNumber(arduinoBoardName,ssd1,digitOne);
  24. onSSD(arduinoBoardName,ssd1Ground);
  25. offSSD(arduinoBoardName,ssd1Ground);
  26.  
  27. displayNumber(arduinoBoardName,ssd2,digitTwo);
  28. onSSD(arduinoBoardName,ssd2Ground);
  29. offSSD(arduinoBoardName,ssd2Ground);
  30.  
  31. displayNumber(arduinoBoardName,ssd3,digitThree);
  32. onSSD(arduinoBoardName,ssd3Ground);
  33. offSSD(arduinoBoardName,ssd3Ground);
  34.  
  35. displayNumber(arduinoBoardName,ssd4,digitFour);
  36. onSSD(arduinoBoardName,ssd4Ground);
  37. offSSD(arduinoBoardName,ssd4Ground);
  38. end
  39. end
  40.  
  41. delete(instrfind({'Port'},{'COM7'}))
  42. ab=arduino('COM7');
  43.  
  44. ssd1=2:8;
  45. ssd2=2:8;
  46. ssd3=2:8;
  47. ssd4=2:8;
  48. ssd1Ground=9;
  49. ssd2Ground=10;
  50. ssd3Ground=11;
  51. ssd4Ground=12;
  52. for x=2:14
  53. pinMode(ab,x,'OUTPUT');
  54. end
  55.  
  56. p=0;
  57.  
  58. while 1
  59. for x=0:9999
  60. displayFourDigitsFor(ab,x,ssd1,ssd1Ground,ssd2,ssd2Ground,ssd3,ssd3Ground,ssd4,ssd4Ground,2);
  61. end
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement