Guest User

Untitled

a guest
Apr 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. let distance = 0
  2. bluetooth.onBluetoothConnected(() => {
  3. basic.showLeds(`
  4. . # # . .
  5. . # . # .
  6. . # # . .
  7. . # . # .
  8. . # # . .
  9. `)
  10. })
  11. bluetooth.onBluetoothDisconnected(() => {
  12. basic.showLeds(`
  13. . # . # .
  14. . # . # .
  15. . . . . .
  16. # . . . #
  17. . # # # .
  18. `)
  19. })
  20. sbrick.onConnected(() => {
  21. basic.showLeds(`
  22. . # # # .
  23. . # . . .
  24. . . # . .
  25. . . . # .
  26. . # # # .
  27. `)
  28. sbrick.setDevice(SBConnectedDevice.Wedo1Motion, SBPort.C)
  29. })
  30. sbrick.onMeasurement(() => {
  31. distance = sbrick.measuredValue() - 200
  32. led.plotBarGraph(
  33. distance,
  34. 220
  35. )
  36. if (distance <= 100) {
  37. sbrick.drive(255, SBPort.D, SBDirection.Forward)
  38. } else {
  39. sbrick.brake(SBPort.D)
  40. }
  41. })
  42. basic.showLeds(`
  43. . # . # .
  44. . # . # .
  45. . . . . .
  46. # . . . #
  47. . # # # .
  48. `)
  49. sbrick.connect("SBrick1")
Add Comment
Please, Sign In to add comment