Sunday, November 29, 2015

Week 4 - Adventures in Making - Electronic Dice Machine

This week's challenge was the Electronic Dice Machine that would generate a random number using 7 LED's  to simulate the possible combinations that you may get when you roll the dice.   I found the project to be fun and challenging.  I want to give a shout out to Nichole Hahn for trying to help me understand the code.  Interestingly enough, I understand the code and was able to writing and find some additional code pieces that I was able to use to construct a automatic random number generator that works just fine.  However, I can't seem to get my button to work for manual number generation.  This is something I will work on later.  Check out my video of  my automatic random number generator and my manual number generator that I am still working on. 

 
Here is the chart from my random number generator:
 
Here is the code for my automatic electronic dice machine:
 
 //Pin to to turn dice on & off
int button = 2;

//LED for DICE
int bottomLeft = 7;
int bottommiddleLeft = 8;
int uppermiddleLeft = 9;
int upperLeft = 10;
int bottomRight = 11;
int middleRight = 12;
int upperRight = 13;
int BUTTON;
int val =0;
int state = 0;
long randNumber;

//Initial setup
void setup()
  {
  pinMode(bottomLeft, OUTPUT);
  pinMode(bottommiddleLeft, OUTPUT);
  pinMode(uppermiddleLeft, OUTPUT);
  pinMode(upperLeft, OUTPUT);
  pinMode(bottomRight, OUTPUT);
  pinMode(middleRight, OUTPUT);
  pinMode(upperRight, OUTPUT);
 
  pinMode(button, INPUT);
 
  Serial.begin(9600);
  randomSeed(analogRead(0));

**This loop allows it to continuously generate a new number combination

}
 void loop(){
  if(digitalRead(button) == HIGH && state == 0){
  //if(val == HIGH) && (state == 0)
  state = 1;
  randNumber = random(1, 7);
  delay(50);
  Serial.println(randNumber);
  if (randNumber == 6){
   six();
  }
  if (randNumber == 5){
   five();
  }
  if (randNumber == 4){
   four();
  }
  if (randNumber == 3){
   three();
  }
  if (randNumber == 2){
   two();
  }
  if (randNumber == 1){
   one();
  }
  delay(1000);
  clearAll();
  state = 0;
 }
}
//Creates a function for each  sides of the die
 void six()
{
  digitalWrite(bottomLeft, OUTPUT);
  digitalWrite(bottommiddleLeft, OUTPUT);
  digitalWrite(uppermiddleLeft, OUTPUT);
  digitalWrite(upperLeft, OUTPUT);
  digitalWrite(bottomRight, OUTPUT);
  digitalWrite(middleRight, OUTPUT);
  digitalWrite(upperRight, OUTPUT);
}
void five()
{
 digitalWrite(upperLeft, HIGH);
 digitalWrite(bottomLeft, HIGH);
 digitalWrite(uppermiddleLeft, HIGH);
 digitalWrite(upperRight, HIGH);
 digitalWrite(bottomRight, HIGH);
}
void four()
{
 digitalWrite(upperLeft, HIGH);
 digitalWrite(bottomLeft, HIGH);
 digitalWrite(upperRight, HIGH);
 digitalWrite(bottomRight, HIGH);
}
void three()
{
 digitalWrite(upperLeft, HIGH);
 digitalWrite(uppermiddleLeft, HIGH);
 digitalWrite(bottomRight, HIGH);
}
void two()
{
 digitalWrite(bottomRight, HIGH);
 digitalWrite(upperLeft, HIGH);
}
void one(){
 digitalWrite(uppermiddleLeft, HIGH);
}
void clearAll(){
 digitalWrite(bottomLeft, LOW);
  digitalWrite(bottommiddleLeft, LOW);
  digitalWrite(uppermiddleLeft, LOW);
  digitalWrite(upperLeft, LOW);
  digitalWrite(bottomRight, LOW);
  digitalWrite(middleRight, LOW);
  digitalWrite(upperRight, LOW);
}
 
Here is the code from my manual electronic dice machine that I am still working on:
 
//Pin to turn dice on & off
int button = 2;
 
//LED for DICE
int bottomLeft = 7;
int bottommiddleLeft = 8;
int uppermiddleLeft = 9;
int upperLeft = 10;
int bottomRight = 11;
int middleRight = 12;
int upperRight = 13;

int val = 0;
int state = 0;
long randNumber;

//Initial setup
void setup()
  {
  pinMode(bottomLeft, OUTPUT);
  pinMode(bottommiddleLeft, OUTPUT);
  pinMode(uppermiddleLeft, OUTPUT);
  pinMode(upperLeft, OUTPUT);
  pinMode(bottomRight, OUTPUT);
  pinMode(middleRight, OUTPUT);
  pinMode(upperRight, OUTPUT);
 
  pinMode(button, INPUT);
 
  Serial.begin(9600);
  //randomSeed(analogRead(0));
}
void loop(){
  int val;
  int buttonState;
  buttonState = digitalRead(button);
  if (buttonState == HIGH)
  
   if (val == HIGH){
       digitalWrite(bottomLeft, LOW);
       digitalWrite(bottommiddleLeft, LOW);
       digitalWrite(uppermiddleLeft, LOW);
       digitalWrite(upperLeft, LOW);
       digitalWrite(bottomRight, LOW);
       digitalWrite(middleRight, LOW);
       digitalWrite(upperRight, LOW);
       delay(250);
     randNumber = random(1, 7);
   }
     if (randNumber == 1){
       digitalWrite(uppermiddleLeft, HIGH);
     }
      if (randNumber == 2){
       digitalWrite(bottomLeft, HIGH);
       digitalWrite(upperRight, HIGH);
     }
    
     if (randNumber == 3){
       digitalWrite(bottomLeft, HIGH);
       digitalWrite(upperLeft, HIGH);
       digitalWrite(upperRight, HIGH);
     }
      if (randNumber == 4){
       digitalWrite(bottomLeft, HIGH);
       digitalWrite(uppermiddleLeft, HIGH);
       digitalWrite(bottomRight, HIGH);
       digitalWrite(upperRight, HIGH);
     }
      if (randNumber == 5){
       digitalWrite(bottomLeft, HIGH);
       digitalWrite(uppermiddleLeft, HIGH);
       digitalWrite(upperLeft, HIGH);
       digitalWrite(bottomRight, HIGH);
       digitalWrite(upperRight, HIGH);
     }
      if (randNumber == 6){
       digitalWrite(bottomLeft, HIGH);
       digitalWrite(bottommiddleLeft, HIGH);
       digitalWrite(uppermiddleLeft, HIGH);
       digitalWrite(bottomRight, HIGH);
       digitalWrite(bottomRight, HIGH);
       digitalWrite(upperRight, HIGH);
     }
   }
 
I like my automatic electronic dice machine.  But I am still working on my manual electronic dice machine, because I know that it will working when I find what is not working with the button. 
 
  Here is a picture of my board configuration:
 
 
SketchUp
 
SketchUp is a really great designing tool.  I enjoyed getting familiar with all of the tools it has available for designing my MakerSpace.  I have in fact purchase a one year student copy because I know I will be able to use it for other designing purposes as well.    I am just getting started but here is a picture of my starting design project:
 
 
I am really going to enjoy designing my MakerSpace with SketchUp.



Sunday, November 22, 2015

Week 3 - Adventures in Making


     This week’s Adventures in Making was about the RGB LED and using Loops, Arrays and Analog Read/Write.  This week’s # 3 circuit was particularly challenging for me because of a reason I have not figured out yet, I could not get it to work.
 
 
  I spent entirely too much time (2 ½ days) trying to figure out why I could not get this circuit to work.  I just was not going to let this go without me solving it.  I even reconfigured my board back to circuit # 1 just to make sure my breadboard had not burned out.  Circuit # 1 worked just fine as it had before. I tried to alter the code in several different edits:
  

         I even striped out all of the comments and tried to run it, alas no joy!
 
         I even went so far as to go to a couple of the local electronics stores (Fry’s and Microcenter) trying to find replacement RGB LEDs to eliminate the possibility that I had a defective RGB LED. After spending a lengthy time at Fry's going through the LED at Fry's and getting a sales tech involved, who, after searching through them  concluded that they were online and not in the store, I proceed to go to Microcenter.  For those of you who don't know, Microcenter is another great electronics store on US 75 and Spring Valley in Richardson.  They actually have a Hobbyist section that has several electronic Maker kits.  I found the 4 pin RGB LEDs at Microcenter and bought the last two packs the store had.
        When I made it home, I tried one of the new LEDs, but still no joy.  So I finally succumb to the fact that, though I may be able to figure it out later, which I think has to be my code, I didn't have enough time right now and needed to try circuit # 4.  I had absolutely no problem configuring the Arduino with circuit # 4.  I ran the code that is in the USK without editing it in any fashion (including the all of the comments) due to lack of time and a small confidence factor because I wanted to see if it would run, after my experience with not being able to get circuit # 3 to work. 
 
   It ran as advertised :
 
I have not included my usual Microsoft Visio drawings this week due to lack of time from my frustrating experience with the Circuit # 3 failure.  I am not going to count circuit # 3 as a failure.  Just lack of time to finish troubleshooting right now.

Sunday, November 15, 2015

Week 2- Adventures in Making - Potentiometer


What the project is supposed to do.

This week's project was a demonstration of how to vary the voltage using a potentiometer in the circuit.  A potentiometer can be used to vary voltage using an analog resistance, rather than the steady on or off state that is supplied from a digital signal.  A digital signal has either an on or off state (0 or 1) as in a light switch.  Using a potentiometer to vary the voltage from the analog side of the board, you can regulate the voltage.

 The code I used  for this project.
int sensorPin = 0;    // The potentiometer is connected to
                                 // analog pin 0 

int ledPin = 13;      // The LED is connected to digital pin 13
 
void setup()         // this function runs once when the sketch starts up
{
   pinMode(ledPin, OUTPUT);
}

void loop() // this function runs repeatedly after setup() finishes
{
   int sensorValue;
   sensorValue = analogRead(sensorPin);   
   digitalWrite(ledPin, HIGH);         // Turn the LED on
  delay(sensorValue);                     // Pause for sensorValue
                                                         // milliseconds 
  digitalWrite(ledPin, LOW);       // Turn the LED off
  delay(sensorValue);                 // Pause for sensorValue
                                                     // milliseconds 
 }
 
A picture of my circuit including Arduino and Breadboard for this project
 

 
An  Visio drawing of my electronic diagram of my week 2 project
 
A couple of YouTube Video of my project
 


Circuit and Code Play
 
See what happens if you use two digital pins rather that one digital and one analog pin:
 
I try to switch the analog pin over to digital, however the light would not function.  I would think that a code change would be necessary in order for this to work.  I will explore this a t a later time.
 
Extension Challenge
 
Can you control 2 lights with the same brightness or same blink rate
 
Yes, plugged a red LED into slot (g) 19 and 20 next to the amber LED and both blinked at the same rate.
 
 
 

Thoughts and Final Reflections:
 
I found this project to fun and informative.  The most challenging part of this project I encountered was having to go out and search the internet for the USK guide to get the proper code for this project.  The code that I originally used, that I thought was the code for the project, did not work.  Although I had a blinking light, the potentiometer was not working.  I knew that there should have been some type of reaction when I turned the potentiometer, but there was no reaction.  The light kept blinking at a steady rate.  
 
What I learned from this project:  I really never understood what component of the electronic circuitry controlled things like volume and attenuation (If that's a word).  I now have a much better understanding of the hardware and software that controls the electronic circuitry. 



 

 

 

 

 

 

 Video explaining the project and how it works.

Saturday, November 7, 2015

Week 1: My First Circuit Board


ETEC 597: Maker Spaces Log:  Star Date 20151107
 
1.   Week 1 Challenge is complete and working (please see my YouTube video at this link:  https://www.youtube.com/watch?v=cLL919L4Mpk )

2.    This project was a pretty simple configuration and coding project for a blinking light.  I found this project to be fun and engaging.  I recalled some of my coding knowledge. The only hiccup was having 2 USB cords laying by the computer and plugging in the wrong one and not get a response from the board (DUH)!
Code for this project

/*
   Blink
   Turns on an LED for one second, then off for one second, repeatedly.
    This example code is in the public domain.
   */
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the seup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH); //turn the LED on (High is the voltage level)
  delay(3000);            //wait for a second
  digitalWrite(led, LOW); //turn the LED off by making the voltage LOW
  delay(3000);            //wait for a second

 Here is a picture of my Week 1 Project

 

Electronic Drawing:

This is my Visio Drawing of my project.


Circuit Play

  1. What happens if you turn the LED around (reverse the wiring)?

  2. It does not work.  The light does not flash.

  1. What happens if you remove the positive lead from the breadboard? Does the circuit still work?
If you remove the positive lead, the board still works, which makes me question the purpose of the positive lead.

  1. What happens if you place the resistor to the positive side of the LED and simply used a wire to run back from the LED to ground? When you do this, you will need to change up the wiring a little so check this closely to make sure you have not shorted out the circuit.
  2. The Pin 13 Troubleshooting light still flashes off and on., if without the LED light.  Does this mean the board is in troubleshooting mode?  I will need to research this.

  1. What happens if you move the wire from port 13 to port 12 on the Arduino?
  2. The Pin 13 Troubleshooting light still flashes off and on., but the LED does not.  Probably because the board is not properly grounded. 
Code Play

  1. If you moved the wire from port 13 to port 12 on the Arduino, what do you need to change in the code?
int led = 12

  1. What happens if you change the two delay code lines from delay(1000) to delay(2000)? Take out a stop watch or timer of some sort and time the rate of blinking for each of these settings. How many times does the LED blink in a minute for each of these settings? What have you learned about the value that is placed between the parenthesis after delay()? What value (parameter) would you place in delay() if you wanted the LED to blink at a rate of once every 3 seconds? How about every half second?

The larger the number, the longer the light stays on, thereby creating the blinking effect.  Therefore, to create a blink every 3 seconds, the value in the delay code has to be delay(3000).  For a half second delay, delay(500).

  1. What happens if you place // before the words void setup()?
  2. What happens if you place // before the words void loop()?
// is for comments and does not act as active code.  When you start a line with //, it is just to make a note so that other coders will know what you are doing with your code.

  1. What happens if you remove the last curly brace “}” in the program?

The program will not run because it is not a completed program.

  1. What happens if you place a // before pinMode(13,HIGH) in setup()?

// is for comments and disables that part of the code.

  1. What happens if you changed HIGH to high on the pinMode(13,HIGH) line?

high (as opposed to HIGH) is not a recognize varirable and will not turn the LED on.  

  1. What happens if you change the word pinMode to pinmode in pinMode(13,HIGH)?

pinmode is not a recognized function and will not set the pin mode.

Final Reflection:

I really enjoyed this first project.  The steps it took to configure the project, includes paying detailed attention to the ports on the bread board and the circuit board may the whole project worthwhile when I finally got it to work. The coding brought back some coding memory that I had not used in a while.  It gave me confidence to continue on.  Can’t wait until the next project.

 
   

Monday, November 2, 2015

Maker Spaces: A New Adventure

     Welcome to my new blog as I adventure into Maker Spaces and Making.  This is my first post for my TAMU-C graduate class, ETEC 597: Maker Spaces: A New Movement in Educational Technology.

     I am truly looking forward to learning about Maker Spaces, as I have always been a sort of a maker without the label.  I have built computers and ticker around with other forms of making without really calling it making.  So this is going to be fun and yet challenging.

Here We Go!