T3kstiil3
Published © Apache-2.0

SoundTouch πŸ”Š Nerf πŸ”« Target 🎯

Create your own Nerf target! If you don't like the music played on the SoundTouch, just hit the target! 🎯

BeginnerFull instructions provided911
SoundTouch πŸ”Š Nerf πŸ”« Target 🎯

Things used in this project

Hardware components

Arduino Yun
Arduino Yun
×1
LED (generic)
LED (generic)
×1
Adafruit Fast Vibration Sensor Switch
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

schematics_laecZG2v8v.png

Code

soundtouch-nerf-target.ino

Arduino
/*
 * Soundtouch Nerf Next target !!!
 * https://github.com/T3kstiil3/soundtouch-nerf-target
 *  AurΓ©lien Loyer :D
 */

#include <Bridge.h>
#include <Console.h>
#include <HttpClient.h>
#include <YunServer.h>
#include <YunClient.h>

YunServer server;

const int statusLED = 13;
const int switchTilt = 2;
int val = 0;

const int port = 8090;
// edit with your soundtouch ip 
const String soundtouchIP = "10.0.10.166";
const String url = "http://" + soundtouchIP + ":8090/key";
const String data = "<?xml version='1.0' encoding='UTF-8' ?><key state='release' sender='Gabbo'>NEXT_TRACK</key>";
const String curlcommand = "curl -H 'Content-Type: application/xml' -X POST -d \"<?xml version='1.0' encoding='UTF-8' ?><key state='press' sender='Gabbo'>NEXT_TRACK</key>\" http://" + soundtouchIP + ":8090/key";

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

  pinMode (statusLED,OUTPUT);
  pinMode (switchTilt,INPUT);

  Bridge.begin();
  server.listenOnLocalhost();
  server.begin();
}

void loop()
{

  YunClient client = server.accept();
  
  val = digitalRead(switchTilt);
  if (val == HIGH){
    digitalWrite(statusLED,HIGH);
    nextTrack();
    delay(30000); // 30 secondes avant le prochain changement !
  }
  else {
    digitalWrite(statusLED,LOW);
  }

  //Process Client Requests
  if (client) {
    process(client);
    client.stop();
  }

  delay(15);
}

void nextTrack() {
  Process p; 
  p.runShellCommand(curlcommand);
}

void process(YunClient client) {
  String command = client.readStringUntil('\r');
}

Credits

T3kstiil3
1 project β€’ 0 followers

Comments