code_junkie

Getting Arduino LilyPad to switch BlueSmirf v2.11 to/from command mode

Nov 11th, 2011
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. // Arduino source code:
  2.  
  3. void setup () {
  4. Serial.begin(9600);
  5. }
  6.  
  7. void loop () {
  8. Serial.print("$$$");
  9. delay(2000); // TODO: Inquiry, etc.
  10. Serial.print("---n");
  11. delay(100);
  12. Serial.print("pingn");
  13. delay(2000);
  14. }
  15.  
  16. // C# source code (runs on PC)
  17.  
  18. using System;
  19. using System.IO.Ports;
  20.  
  21. class Program {
  22.  
  23. static void Main () {
  24. SerialPort p = new SerialPort(
  25. "COM20", 9600, Parity.None, 8, StopBits.One);
  26. using (p) {
  27. p.Open();
  28. while (p.IsOpen) {
  29. Console.Write((char) p.ReadChar());
  30. }
  31. }
  32. }
  33. }
Add Comment
Please, Sign In to add comment