Neto CarrerGustavo Labbate Godoy
Published © GPL3+

Continuous Integration Build Status Semaphore

continouslava-alike project shaped as a Traffic light

IntermediateFull instructions provided1,586
Continuous Integration Build Status Semaphore

Things used in this project

Hardware components

SparkFun WS2812B
×3
DFRduino Nano V3.1
×1

Hand tools and fabrication machines

Prusa i3 (or any other 3D Printer)

Story

Read more

Custom parts and enclosures

Semaphore CAD

Schematics

Wiring Diagram

Code

Semaphore

C/C++
Simple and buggy ino code. But works :|
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif

#define PIN 4
Adafruit_NeoPixel strip = Adafruit_NeoPixel(3, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  Serial.begin(9600);
    #if defined (__AVR_ATtiny85__)
    if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  #endif
  strip.begin();
  strip.show(); 
}

void loop() {
  if( Serial.available()){
    int ch = Serial.read();
        
      if (ch == '1'){
      allOff();
      paintLed(0,0,255,0);
      } 
      else if (ch == '2'){
      allOff();
      paintLed(1,255,255,0);
      }
      else if (ch == '3'){
      allOff();
      paintLed(2,255,0,0);
      }
      else if (ch == '6'){
      allOff();
      }
      else if (ch == '7'){
      allOff();
      building();
      }
  }
}

void building(){
  for (int i=0; i<=5; i++){
    paintLed(0,0,0,255);
     delay(100);
    allOff();
    paintLed(1,0,0,255);
     delay(100);
    allOff();
    paintLed(2,0,0,255);
    delay(100);
    for (int j=0; j<=2; j++){
    allOff();
    paintLed(0,0,0,255);
    paintLed(1,0,0,255);
    paintLed(2,0,0,255);
    delay(100);
    }
  }
}

void paintLed(int led, int red, int green, int blue){
    strip.setPixelColor(led, red, green, blue);
    strip.show();
}


void allOff(){
    strip.setPixelColor(0, 0, 0, 0);
    strip.setPixelColor(1, 0, 0, 0);
    strip.setPixelColor(2, 0, 0, 0);
    strip.show();
 }

 

getJenkinsResults

PHP
The php for read the jenkins xml, get the result and decide what to do...
<?php

function sendSerialSignal($arg_1)
{
//Enter here the serial port that arduino is connected...
	$fp =fopen("COM8", "w+");
	if( !$fp) {
        echo "Error";die();
	}
	sleep(2);
	fwrite($fp, $arg_1);
	fclose($fp);
}

//enter here the url that contains the last build result in jenkins
$map_url = "http://server/jenkins/view/project/job/job_name/lastBuild/api/xml";

if (($response_xml_data = file_get_contents($map_url))===false){
    echo "Error fetching XML\n";
} else {
   libxml_use_internal_errors(true);
   $data = simplexml_load_string($response_xml_data);
   if (!$data) {
       echo "Error loading XML\n";
       foreach(libxml_get_errors() as $error) {
           echo "\t", $error->message;
       }
   } else {
	$result =  $data->result;

	if($result == "SUCCESS" ){
	sendSerialSignal(1);
	} 
	else if($result == "UNSTABLE" ){
	sendSerialSignal(2);
	}
	else if($result == "FAILURE" ){
	sendSerialSignal(3);
	exit();
	}
	else {
	sendSerialSignal(7);
	}
   }
}

exit();


?>

Credits

Neto Carrer

Neto Carrer

3 projects • 7 followers
Gustavo Labbate Godoy

Gustavo Labbate Godoy

1 project • 0 followers

Comments