Computer Club Sample 20180417

/*
*Kellenberg Computer Club
*Sonar Demonstration
*/
// defines pins numbers
const int TriggerPin = 9;
const int EchoPin = 10;
const int GreenLight = 5;
const int RedLight = 6;
 
// defines variables
long duration;
int distance;
 
int LoopCount=0;
int FirstTime=1;
 
 
/*This is the Setup Routine.  The Setup Routine will only execute one time per power cycle
 * or reset of the Arduion device
 */
void setup() {
           
          /*First we configure our pins as INPUT and OUTPUT*/
          pinMode(TriggerPin, OUTPUT); // Sets the pin (9) as output.  It is sending a signal
          pinMode(EchoPin, INPUT); // Sets the pin (10) as Input.  Gets the signal
          pinMode(GreenLight,OUTPUT);
          pinMode(RedLight,OUTPUT);
           
          /*Now we are opening the serial line so that we can
           * Send messages to the serial Monitor
           */
          Serial.begin(9600); // We will us the serial port to monitor what is happening in the serial monitor
          
          /*Now we set the TriggerPin Low in initialize it*/
          digitalWrite(TriggerPin, LOW);
          delayMicroseconds(2);
}
 
/*After setup is called, the loop function is called.  once loop gets to the bottom, starts over again.
 * 
 */
void loop() {
                  
           
          // Sets the TriggerPin on HIGH state for 10 micro seconds
          digitalWrite(TriggerPin, HIGH);
          delayMicroseconds(10);
          digitalWrite(TriggerPin, LOW);
           
          // Reads the echoPin, returns the sound wave travel time in microseconds
          duration = pulseIn(EchoPin, HIGH);
 
          // Calculating the distance
          distance= duration*0.034/2;

          if(distance<100){
            Serial.println("Getting too close");
            digitalWrite(GreenLight,LOW);
            digitalWrite(RedLight,HIGH);
          }else{
            digitalWrite(GreenLight,HIGH);
            digitalWrite(RedLight,LOW);
          }
          delay(500); 
          // Prints the distance on the Serial Monitor
          Serial.print("Distance: ");
          Serial.println(distance);
}

mrcampbell / April 17, 2018 / Uncategorized

main.cpp

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.cpp
 * Author: jfcampbelljr
 *
 * Created on April 10, 2018, 12:15 PM
 */
#include "MainDefs.h"
#include <stdio.h>
#include <Windows.h>
#include <cstdlib>

using namespace std;

extern DWORD ListenThread(LPVOID Parms);
int ProgramRunning=1;
/*
 * 
 */
int main(int argc, char** argv) {
    
    DWORD dwListenThread;
    HANDLE hListenerThread;


    char buffer[BUFFER_SIZE];
    printf("Welcome to Computer 12!\n");
    printf("Type X on a line by itself to end.\n");

    hListenerThread=CreateThread(NULL,0,ListenThread,NULL,0,&dwListenThread );
    if(!hListenerThread){
        printf("Error Creating Server / Listener Thread-Program Terminating\n");
        return(0);
    }else{
        /*In windows a handle is a finite resource*/
        /*Our Program may only have so many handles open*/
        /*If we aren't going to use the handle we should close it*/
        CloseHandle(hListenerThread);
    }

    int counter=0;
    while (ProgramRunning){
        
        Sleep(5000);
    }

    return 0;
}


mrcampbell / April 16, 2018 / Uncategorized

It’s School Club Roundup Time

Attention All! The Kellenberg Amateur Radio Club will be participating in the Winter School Club Roundup running from February 13, 2017 until February 17, 2017. All students are invited to participate in this event. Please see Mr. Campbell for details and to sign up for a time to operate.

mrcampbell / February 6, 2017 / Uncategorized

No meeting Monday 9/26/2016

Due to the debate and road closures all students are encouraged to take their regularly scheduled bus home and we will not hold a meeting on Monday afternoon.  Please check your email for updates.  

mrcampbell / September 25, 2016 / Uncategorized