CJA3D
Published © GPL3+

Darth Vader's Command center

Use the Photon and 3D printed part to make Darth Vader's Command center, which display weather,surf report,tweets and a message from Mom.

IntermediateFull instructions provided10 hours1,580
Darth Vader's Command center

Things used in this project

Hardware components

Photon
Particle Photon
×1
Adafruit Monochrome OLED 1.3''
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Flora RGB Neopixel LEDs- Pack of 4
Adafruit Flora RGB Neopixel LEDs- Pack of 4
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Maker service
IFTTT Maker service

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Custom parts and enclosures

Darth Vader Eyes - with OLED screen slot

3D Print in Black PLA

Left Neopixel difusion part

Print in transparent PLA

Right NeoPixel difusion part

Print with Transparent PLA

pen/pencil Holder

pen/pencil holder

Mouth Base

3D print in black PLA

Top Part back

3D print with black PLA

Helmet base with slots for NeoPixels

Print in black PLA

Schematics

Circuit

- DHT11 sensor to D5
- Potentiometer to A0
- Neopixels (4) connected to A5
- And the screen in SPI, that is
- MOSI to D0
- CLK to D1
- DC D2
- CS D3
- RESET D4

Circuit

- DHT11 sensor to D5
- Potentiometer to A0
- Neopixels (4) connected to A5
- And the screen in the SPI, that is
- MOSI to D0
- CLK to D1
- DC D2
- CS D3
- RESET D4

Code

SendMessage.html

HTML
html page which sends a message to spark function on the photon
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>

<script>
var accessToken = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";//Copy this from the https://build.particle.io/build/new setting section
var deviceID = "XXXXXXXXXXXXXXXX"//Copy this from the Devices section
var url = "https://api.spark.io/v1/devices/" + deviceID + "/MessageMom";
function callback(data, status){

}
function sendMessageMom(){
	message = $("#message").val();
   	$.post(url, {params: message, access_token: accessToken}, callback);
}
</script>

</head>	

<body>

<h1>Send a Message when your ready</h1>	
<input id="message" value="Dinner is ready" size="64"/>
<input type="button" value="Send" onclick="sendMessageMom()" /> <br/>

</body>
</html>

Vader_ssd1306_Neopixel.ino

Arduino
Libraries to include in addition to the ino file
-Neopixel
-DHT11
-Adafruit SSD1306
-Adafruit GFX
/*********************************************************************
This is an example for our Monochrome OLEDs based on SSD1306 drivers

  Pick one up today in the adafruit shop!
  ------> http://www.adafruit.com/category/63_98

This example is for a 128x64 size display using SPI to communicate
4 or 5 pins are required to interface

Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!

Written by Limor Fried/Ladyada  for Adafruit Industries.
BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/
//Modified by @CarmelitoA for Darth Vader Command center project on Hackster.io
#include "Adafruit_GFX.h"
#include "Adafruit_SSD1306.h"
#include "Adafruit_DHT.h"
#include "neopixel.h"

// Connection to OLED using SPI
#define OLED_MOSI   D0
#define OLED_CLK    D1
#define OLED_DC     D2
#define OLED_CS     D3
#define OLED_RESET  D4
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

#define DHTPIN 5    // DHT11 sensor connected to pin 5
#define DHTTYPE DHT11
#define POT A0 //potentiometer connected which will act as mode switch

// NeoPixels Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN A5
#define PIXEL_COUNT 10
#define PIXEL_TYPE WS2812B

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2



#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

DHT dht(DHTPIN, DHTTYPE);
String outside ="";//variable to store the High and Low temperature outside
String weatherCond = "";//Weather condition description
String tweetCheck = "";//twitter check
String surfRep =""; //Check surf report from Surfline.com via IFTTT //Uncomment if your using the surf report recipe
String messageMom=""; //stores message from a web page

void setup()   {
  Serial.begin(9600);
  pinMode(POT, INPUT);
  dht.begin();
  strip.begin();
  strip.show(); // Initialize all NeoPixelspixels to 'off
  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC);
  //this shows the Adafruit splashscreen
  display.display(); // show splashscreen
  delay(2000);
  display.clearDisplay();   // clears the screen and buffer

 Spark.function("SetWeather", SetWeather);//Invoked by the IFTTT recipe
 Spark.function("WeatherCond", WeatherCond);
 Spark.function("TweetCheck", TweetCheck);
 //Commenting this as there is a limimation that you can have only 4 spark functions at a given time
  //Spark.function("SurfReport", SurfReport);
 Spark.function("MessageMom", MessageMom); //this shows a message send from the web page


}


void loop() {
  int potValue = analogRead(POT);
  //rainbow(50); //uncomment to test color diffusion of the neopixel through the 3D printed part

  //Posting the Pot value to the screen for testing so that you can get an idea of the ranges
 //COMMENT OUT THIS SECTION ONCE YOU DECIDE ON THE VALUES FOR YOUR DIAL aka the POT
  display.setCursor(0,0);
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.println("Pot Value:" +String(potValue));
  display.display();
  delay(2000);
  display.clearDisplay();

  if(potValue > 4000)
  {
    // draw scrolling text - display your fav quote/message
    testscrolltext();
    delay(1000);
    display.clearDisplay();
    //reset NeoPixels
    neopixelOff();
    //reset message from the HTML page
    messageMom="";
  }else if (potValue >3000 && potValue < 4000){
    // Reading temperature and humidity to diplay on the OLED screen
    	float h = dht.getHumidity();
    // Read temperature as Celsius
    	float t = dht.getTempCelcius();
    // Check if any reads failed and exit early (to try again).
    	if (isnan(h) || isnan(t)) {
    		Serial.println("err ... \n Failed to read \n from DHT sensor!");
    		return;
    	}
      // text display Temperature and Humidity inside your home
      display.setTextSize(1);
      display.setTextColor(WHITE);
      display.setCursor(0,0);
      display.println("Inside"); //Time.timeStr()
      display.setTextSize(2);
      display.setTextColor(WHITE);
      display.println("Temp :" +String(int(t)) + " C");
      display.setTextSize(2);
      display.setTextColor(WHITE);
      display.println("Humid:" +String(int(h)) + " %");
      display.display();
      delay(2000);
      display.clearDisplay();
 }else if (potValue >2000 && potValue < 3000){
   // Display temperature HIGH and LOW, outside using a recipe on IFTTT
   if (outside.length() > 0)
   {
     display.setTextSize(1);
     display.setCursor(10,0);
     display.setTextColor(WHITE);
     display.println("Outside");
     display.setTextSize(2);
     display.setTextColor(WHITE);
     display.println(outside);
     display.display();
     delay(2000);
     display.clearDisplay();
   }else{
     display.setTextSize(1);
     display.setCursor(10,0);
     display.setTextColor(WHITE);
     display.println("err....\n Outside Weather \n not avaliable..");
     display.display();
     delay(2000);
     display.clearDisplay();
   }

 }else if (potValue >1000 && potValue < 2000){
   // Display Weather Condition using a recipe on IFTTT
   if (weatherCond.length() > 0)
   {
     display.setTextSize(2);
     display.setCursor(10,0);
     display.setTextColor(WHITE);
     display.println(weatherCond);
     display.display();
     delay(2000);
     display.clearDisplay();
   }else{
     display.setTextSize(1);
     display.setCursor(10,0);
     display.setTextColor(WHITE);
     display.println("err....\nWeather Condition \n not avaliable..");
     display.display();
     delay(2000);
     display.clearDisplay();
   }

 }else if (potValue >200 && potValue < 1000)
 {
  //Display the surf report if the fair-good , Condition mentioned in IFTTT recipe
  if (surfRep.length() > 0)
  {
    display.setTextSize(1);
    display.setCursor(10,0);
    display.setTextColor(WHITE);
    display.println(surfRep);
    display.display();
    delay(2000);
    display.clearDisplay();
  }else{
    display.setTextSize(1);
    display.setCursor(10,0);
    display.setTextColor(WHITE);
    display.println("No Surf report \n check surfline.com..");
    display.display();
    delay(2000);
    display.clearDisplay();
  }

 }else{
   // Display tweet in which your mentioned-  @{{UserName}} : {{Text}}
   if (tweetCheck.length() > 0)
   {
     display.setTextSize(1);
     display.setCursor(10,0);
     display.setTextColor(WHITE);
     display.println(tweetCheck);
     display.display();
     delay(2000);
     display.clearDisplay();
     neopixelBlue();
   }else{
     display.setTextSize(1);
     display.setCursor(10,0);
     display.setTextColor(WHITE);
     display.println("Sad !! No mentions.. ");
     display.display();
     delay(2000);
     display.clearDisplay();
   }
 }

//Display message from MOM sent from the HTML page
if (messageMom.length() > 0)
{
  display.setTextSize(1);
  display.setCursor(10,0);
  display.setTextColor(WHITE);
  display.println(messageMom);
  display.display();
  rainbow(50);//run a rainbow color
  delay(6000);
  display.clearDisplay();
}

}//end of loop

//Spark functions
int SetWeather(String message) {
  outside = message ;
}

int WeatherCond(String message) {
  weatherCond = message;
}

int TweetCheck(String message) {
  tweetCheck = message;
}
/*int SurfReport(String message) {
  surfRep = message;
}*/ //Uncomment if you plan to use the surfline recipe
int MessageMom(String message) {
  messageMom = message;
}

void testscrolltext(void) {
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(10,0);
  display.clearDisplay();
  display.println("Thanks to  \n Hackster.io \n and  \n Particle.io"); //changed to your personalized message or Quote
  display.display();

  display.startscrollright(0x00, 0x0F);
  delay(2000);
  display.stopscroll();
  delay(1000);
  display.startscrollleft(0x00, 0x0F);
  delay(2000);
  display.stopscroll();
  delay(1000);
  display.startscrolldiagright(0x00, 0x07);
  delay(2000);
  display.startscrolldiagleft(0x00, 0x07);
  delay(2000);
  display.stopscroll();
}
void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}
void neopixelOff(){
  uint16_t i;
  for(i=0; i<strip.numPixels(); i++) {
  strip.setPixelColor(i, strip.Color(0, 0, 0)); //all Pixels off
  delay(500);
  strip.show();
  }
}
void neopixelBlue(){
  uint16_t i;
  for(i=0; i<strip.numPixels(); i++) {
  strip.setPixelColor(i, strip.Color(0, 0, 255)); //all Blue
  delay(500);
  strip.show();
  }
}

Credits

CJA3D

CJA3D

10 projects • 80 followers
Tinkerer and 3D Printing enthusiast.

Comments