circuito.io team
Published © GPL3+

Office Neighbor Shield with Arduino

In the following project, we'll show you how to make an Arduino-controlled office neighbor shield.

AdvancedShowcase (no instructions)8 hours1,913
Office Neighbor Shield with Arduino

Things used in this project

Hardware components

SparkFun Stepper Motor with Cable
×1
SparkFun Wall Adapter Power Supply - 12VDC 600mA
×1
SparkFun Breadboard - Full-Size (Bare)
×1
SparkFun EasyDriver - Stepper Motor Driver
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
USB-A to B Cable
USB-A to B Cable
×1
SparkFun Jumper Wires - Connected 6" (M/F, 20 pack)
×1
Arduino UNO
Arduino UNO
×1
SparkFun Jumper Wires Standard 7" M/M - 30 AWG (30 Pack)
×1

Software apps and online services

circuito.io
https://www.circuito.io/app?selectedComponentsIds=11021&selectedComponentsIds=9238&selectedComponentsIds=9442&selectedComponentsIds=9939

Story

Read more

Custom parts and enclosures

Build the screen holder

We took a simple screen, like the ones you can get in Ikea and made the screen holder out of an aluminum profile. You can be creative here and make a different holder with scraps you have in your workshop.

Basically, you will need to measure the length of your curtain, cut and bend the profile accordingly and drill holes in it for the stepper. For the handle we used a simple aluminum pipe and 3D printed the handle.

Schematics

curtain schematics

Code

Curtain code

C/C++
1. Open the Firmware folder
2. Open the Firmware.ino file
3. Copy the new code in the attached file, and replace the original code.
4. Upload the code, and test to see that it works. You may need to make adjustments if you build the screen holder differently than what we did.
No preview (download only).

FJ1PJDJIOLUKZMF.txt

C/C++
#include "Global.h"

const int DELTA_THRESHOLD = 5;    // Any change below this threshold will not be performed, to smooth random noise in readings
const float STEPPER_RATIO = 0.15;  // Mapping ration between potentiometer and stepper movement
const int STEP_INTERVAL   = 1000; // Stepper Driver timing in us (probably no need to change this parameter)
int curPos = 0;                   // Remember the stepper's current position
const int numReadings = 500;
int readings[numReadings];      // the readings from the analog input
int readIndex = 0;              // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average




void setup() {
  // Setup Serial which is useful for debugging
  // Use the Serial Monitor to view printed messages
  Serial.begin(9600);
  Serial.println("start");
    for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;
  }
  stepperMotor.write(0, 1000, STEP_INTERVAL);

}

void loop() {
  int mappedPotVal = potentiometer.read();
  mappedPotVal = map(mappedPotVal, 221, 950, 0, 1024);
 
 // subtract the last reading:
  total = total - readings[readIndex];
  // read from the sensor:
  readings[readIndex] = mappedPotVal;
  // add the reading to the total:
  total = total + readings[readIndex];
  // advance to the next position in the array:
  readIndex = readIndex + 1;

  // if we're at the end of the array...
  if (readIndex >= numReadings) {
    // ...wrap around to the beginning:
    readIndex = 0;
  }

  // calculate the average:
  average = total / numReadings;
  // send it to the computer as ASCII digits
// Serial.println(average);


  



  int targetPos = mappedPotVal * STEPPER_RATIO;
  int deltaPos = targetPos - curPos;


  // if the difference is pos is very small, don't do anything
  if (abs(deltaPos) < DELTA_THRESHOLD)
  {
    delay(1);
    return;
  }

  // Determine correct direction to move
  if (deltaPos > 0)
    stepperMotor.write(1, abs(deltaPos), STEP_INTERVAL);
  else
    stepperMotor.write(0, abs(deltaPos), STEP_INTERVAL);

  curPos = targetPos;


}

Credits

circuito.io team

circuito.io team

29 projects • 595 followers
Circuito.io is an online platform that generates wiring and code for Arduino projects. Want to know more? Visit http://circuito.io

Comments