Gustavo Reynaga
Published © GPL3+

BLE Larson Scanner (Hackster Box Project)

Create your Larson (Cylon or Kit Car) Scanner, controlled by BLE with the Arduino 101, made with Hackster Box

BeginnerShowcase (no instructions)1 hour6,122
BLE Larson Scanner (Hackster Box Project)

Things used in this project

Hardware components

Arduino 101
Arduino 101
×1
Resistor 150 ohm
×1
Red Led
×1
Wires
×1
Hackster Box
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
MIT App Inventor App Inventor

Story

Read more

Schematics

Fritzing Schematic Larson Scanner

Fritzing Schematic Larson Scanner

Code

BLE Larson Scanner INO

Arduino
/*
 * Larson BLE Scanner made by Gustavo Reynaga @gsreynaga based on:
 * KITT emulator! Created By John Boxall http://tronixstuff.com
 * &
 * Copyright (c) 2016 Intel Corporation.  All rights reserved.
 * See the bottom of this file for the license terms.
 */

#include <CurieBLE.h>

BLEPeripheral blePeripheral;  // BLE Peripheral Device (the board you're programming)
BLEService LarsonService("19B10010-E8F2-537E-4F6C-D104768A1214"); // BLE Larson Scanner Service

// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEUnsignedCharCharacteristic switchCharacteristic("19B10011-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);

void setup() {
  Serial.begin(115200);

  // set LEDs pin to output mode
  
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);

  // set advertised local name and service UUID:
  blePeripheral.setLocalName("LARSON");
  blePeripheral.setAdvertisedServiceUuid(LarsonService.uuid());

  // add service and characteristic:
  blePeripheral.addAttribute(LarsonService);
  blePeripheral.addAttribute(switchCharacteristic);

  // set the initial value for the characeristic:
  switchCharacteristic.setValue(0);

  // begin advertising BLE service:
  blePeripheral.begin();

  Serial.println("BLE LED Peripheral");
}

void loop() {
  // listen for BLE peripherals to connect:
  BLECentral central = blePeripheral.central();

  // if a central is connected to peripheral:
  if (central) {
    Serial.print("Connected to central: ");
    // print the central's MAC address:
    Serial.println(central.address());

    // while the central is still connected to peripheral:
    while (central.connected()) {
      // if the remote device wrote to the characteristic,
      // use the value to control the LED:
        if (switchCharacteristic.written()) {
        Serial.println(switchCharacteristic.value());
          int del = switchCharacteristic.value(); //Assign value to "del" variable
        
          digitalWrite(3, HIGH);   // turn on LED on pin 3
          delay(del);              // wait
          digitalWrite(3, LOW);    // turn it off
          digitalWrite(4, HIGH);   // turn on LED on pin 4
          delay(del);              // wait
          digitalWrite(4, LOW);    // turn it off
          digitalWrite(5, HIGH);   // turn on LED on pin 5
          delay(del);              // wait
          digitalWrite(5, LOW);    // turn it off
          digitalWrite(6, HIGH);   // turn on LED on pin 6
          delay(del);              // wait
          digitalWrite(6, LOW);    // turn it off
          digitalWrite(7, HIGH);   // turn on LED on pin 7
          delay(del);              // wait
          digitalWrite(7, LOW);    // turn it off
          digitalWrite(8, HIGH);   // turn on LED on pin 8
          delay(del);              // wait
          digitalWrite(8, LOW);    // turn it off
        
          digitalWrite(8, HIGH);   // turn on LED on pin 8
          delay(del);              // wait
          digitalWrite(8, LOW);    // turn it off
          digitalWrite(7, HIGH);   // turn on LED on pin 7
          delay(del);              // wait
          digitalWrite(7, LOW);    // turn it off
          digitalWrite(6, HIGH);   // turn on LED on pin 6
          delay(del);              // wait
          digitalWrite(6, LOW);    // turn it off
          digitalWrite(5, HIGH);   // turn on LED on pin 5
          delay(del);              // wait
          digitalWrite(5, LOW);    // turn it off
          digitalWrite(4, HIGH);   // turn on LED on pin 4
          delay(del);              // wait
          digitalWrite(4, LOW);    // turn it off
                  
        } else {                              // a 0 value
          Serial.println(F("Scanner off"));
          //digitalWrite(ledPin, LOW);          // will turn the LED off

          digitalWrite(3, LOW);    // turn it off
          digitalWrite(4, LOW);    // turn it off
          digitalWrite(5, LOW);    // turn it off
          digitalWrite(6, LOW);    // turn it off
          digitalWrite(7, LOW);    // turn it off
          digitalWrite(8, LOW);    // turn it off
          
        }
      }
    

    // when the central disconnects, print it out:
    Serial.print(F("Disconnected from central: "));
    Serial.println(central.address());
  }
}

/*
   Copyright (c) 2016 Intel Corporation.  All rights reserved.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

BLE Larson Scanner AIA Source File

XML
Source Project for App Invnetor
No preview (download only).

BLE Larson Scanner APK File

XML
Android App APK file
No preview (download only).

Credits

Gustavo Reynaga

Gustavo Reynaga

12 projects • 85 followers
Iam a teacher

Comments