Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. //// Functions that save RAM memory by putting strings into program ROM
  2. //// created by Limor of LadyAda.net
  3. void ROM_putstring(const char *str, uint8_t nl) {
  4. uint8_t i;
  5.  
  6. for (i=0; pgm_read_byte(&str[i]); i++) {
  7. uart_putchar(pgm_read_byte(&str[i]));
  8. }
  9. if (nl) {
  10. uart_putchar('\n'); uart_putchar('\r');
  11. }
  12. }
  13.  
  14. void ROM_putstringSS(const char *str, uint8_t nl) {
  15. uint8_t i;
  16.  
  17. for (i=0; pgm_read_byte(&str[i]); i++) {
  18. uart_putcharSS(pgm_read_byte(&str[i]));
  19. }
  20. if (nl) {
  21. uart_putcharSS('\n');
  22. }
  23. }
  24.  
  25. void uart_putchar(char c) {
  26. while (!(UCSR0A & _BV(UDRE0)));
  27. UDR0 = c;
  28. }
  29.  
  30. void uart_putcharSS(char c) {
  31. Serial.print(c);
  32. }
  33.  
  34.  
  35. // this function blinks the an LED light as many times as requested
  36. void blinkLED(byte targetPin, int numBlinks, int blinkRate) {
  37. for (int i=0; i<numBlinks; i++) {
  38. digitalWrite(targetPin, HIGH); // sets the LED on
  39. delay(blinkRate); // waits for a blinkRate milliseconds
  40. digitalWrite(targetPin, LOW); // sets the LED off
  41. delay(blinkRate);
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement