Friday, March 10, 2017

March 10th- GRNG 201's


Eric and Maggie added siding to the main tank:



Spencer was absent, so I worked on running Neopixels with the Arduino:




/* Neopixel Ring- Single Red LED spins around circle; can be powered by +5V pin.

//if lots of LEDs need to be turned on at the same time, you can use an L298N Motor driver as a 5V supply( connect GND to GND, Vin(+12) to +12V, 5V out to Neopixels  power lead[red]


To avoid damage to Neopixels  add a 500 ohm resistor into data line  and 1000 uF capacitor across 5V supply. See Adafruit Neopixel Uberguide Best Practices
 https://learn.adafruit.com/adafruit-neopixel-uberguide/best-practices
 */ 


#include <Adafruit_NeoPixel.h>
#include <avr/power.h>
#define PIN            6  //data pin #

// How many NeoPixels are attached to the Arduino?

#define NUMPIXELS      24

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {

  pixels.begin(); // This initializes the NeoPixel library.
}

void loop() {

  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.

  for (int i = 0; i < NUMPIXELS; i++) {

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(50, 0, 0)); // Moderately bright green color.
    pixels.show(); // This sends the updated pixel color to the hardware.
    delay(10);
    pixels.setPixelColor(i, pixels.Color(0, 0, 0)); // Moderately bright green color.
    delay(10);

  }

}

----------------------------------------------------------------------------------------------------


Stepper Motor:






M1: Red/Green  M2:Yellow/Blue



/*
  Simpler Stepper Motor Control using Adafruit Motor Shiled V2
  Wiring: Power Arduino Uno with 12V power Supply
  Attach Adafruit V2 Motor Shield
  Leave Vin Power jumper in place
  Attach stepper motor wires to M1(Red/Green) and M2(Yellow/Blue)
*/

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"

int dollops = 3;// set number of food dollops per feeding

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();

// Connect a stepper motor with 200 steps per revolution (1.8 degree)
// to motor port #1 (M1 and M2)
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 1);


void setup() {

  AFMS.begin();  // create with the default frequency 1.6KHz
  myMotor->setSpeed(10);  // 10 rpm
}

void loop() {

  dispenseFood(dollops);//dispense food
  delay(60000); // wait one minute-- change to desired interval
}


void dispenseFood( dollops)
{
  for ( int i = 0; i < dollops; i++) {
    myMotor->step(100, FORWARD, DOUBLE);//turn halfway around
    delay(1000);
    myMotor->step(100, BACKWARD, DOUBLE);//turn back
    delay(1000);
  }

}

No comments:

Post a Comment