Home

When does your warranty expire?

Leave a comment

Chit chat

======

Grep:

$ grep -l -e “searchterm” *just get the file names

Use sudo without having to retype the command

updatedsudo

Got a bunch off goodies to play with for the Arduino. wifi, ethernet, and ping sensors.

We recommend not using companies that are removing confederate merchandise from their shelves.

Screenshot from 2015-06-25 17:30:17

Basis for a new project ust a touchpad plus an rpi.

Screenshot from 2015-06-28 15:19:57

—————————————-

Cartoons:

Screenshot from 2015-06-29 00:49:13

Screenshot from 2015-06-29 00:12:01

Screenshot from 2015-06-28 23:38:19

—————————————-

Power supplies either home made or commercial switching. Home made can be made iwht parts around the shop or local electronics store. Tendds to run hot and  not that efficent. Switching power supplies can be ought dirt cheap, use less electricity and are the most efficient.

Screenshot from 2015-06-27 04:04:18

Another circuit.

GI83o

—————————————-

Experimental code fir the 4 prong ping detector (vs the 3 ping from Paralax)

Screenshot from 2015-06-29 16:01:58

/* HC-SR04 Sensor
   https://www.dealextreme.com/p/hc-sr04-ultrasonic-sensor-distance-measuring-module-133696

   This sketch reads a HC-SR04 ultrasonic rangefinder and returns the
   distance to the closest object in range. To do this, it sends a pulse
   to the sensor to initiate a reading, then listens for a pulse
   to return.  The length of the returning pulse is proportional to
   the distance of the object from the sensor.

   The circuit:
	* VCC connection of the sensor attached to +5V
	* GND connection of the sensor attached to ground
	* TRIG connection of the sensor attached to digital pin 2
	* ECHO connection of the sensor attached to digital pin 4

   Original code for Ping))) example was created by David A. Mellis
   Adapted for HC-SR04 by Tautvidas Sipavicius

   This example code is in the public domain.
 */

const int trigPin = 2;
const int echoPin = 4;

void setup() {
  // initialize serial communication:
  Serial.begin(9600);
}

void loop()
{
  // establish variables for duration of the ping,
  // and the distance result in inches and centimeters:
  long duration, inches, cm;

  // The sensor is triggered by a HIGH pulse of 10 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  pinMode(trigPin, OUTPUT);
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Read the signal from the sensor: a HIGH pulse whose
  // duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(echoPin, INPUT);
  duration = pulseIn(echoPin, HIGH);

  // convert the time into a distance
  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);

  Serial.print(inches);
  Serial.print("in, ");
  Serial.print(cm);
  Serial.print("cm");
  Serial.println();

  delay(100);
}

long microsecondsToInches(long microseconds)
{
  // According to Parallax's datasheet for the PING))), there are
  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
  // second).  This gives the distance travelled by the ping, outbound
  // and return, so we divide by 2 to get the distance of the obstacle.
  // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
  return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds)
{
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;
}

—————————————-

Simple Arduino emf detector. (bug detector?) Lamp[ seems to blink faster and brighter around magnetic fields. (could not get this to work.)

Screenshot from 2015-06-27 16:05:58


int inPin = 5;             // analog 5
int val = 0;                 // where to store info from analog 5
int pin11 = 11;         // output of red led

void setup() {

Serial.begin(9600);

}

void loop() {

val = analogRead(inPin);                    // reads in the values from analog 5 and
//assigns them to val
if(val >= 1){

val = constrain(val, 1, 100);               // mess with these values
val = map(val, 1, 100, 1, 255);        // to change the response distance of the device
analogWrite(pin11, val);                    // *note also messing with the resistor should change
// the sensitivity
}else{                                                     // analogWrite(pin11, val); just tuns on the led with
// the intensity of the variable val
analogWrite(pin11, 0);                     // the else statement is just telling the microcontroller
// to turn off the light if there is no EMF detected
}

Serial.println(val);                                // use output to aid in calibrating

}

—————————————-

When it comes to home automation, you could use any number of systems such as a off the shelf turnkey solution such as Insteon.Check with your hardware store for more details. You could build it yourself. Unless you are experienced at it, I would let a professional do it, if for no other reason of safety to yourself and others.  If you do do it yourself, you will have to write the software to make it all happen. Though most of it may not be that hard, it can be daunting to the inexperienced. Again get a professional and a mentor. Also any drawings in this article are oversimplified and not to be used in actual systems.  What to do first? You want to make a plan of what you want to do including any budget considerations. (What is it going to cost?)

Home Automation – Requirements ChecklistFunctional Areas:
Controls
Standalone time-based controllers
Remote infrared or wireless (RF) controllers
Local PC only
Local PC w/Internet access enabled
Optional telephone interface for status and control
    Security & Monitoring
Alarm System Integration
Standalone system with outputs
Standalone system with auxiliary inputs/outputs
Custom Alarm System
Motion detectors (people or vehicles)
Security cameras (archive motion triggered video clips)
Zone intrusion detectors (infrared)
Local siren alarm
Alerts (pager or email or dial-out)
Door/Window/Gate open sensor
Barking dog deterrent
Flood lightsActivity Monitoring
Cameras to monitor children or pets
Pet feeders, pet doors, automatic cleaners, pet containment
Electronic door latches
Activity logs
Disaster Recovery
Sensors: water level, extreme temperatures, wind, smoke, rain
Alerts (pager or email or emergency dial-out)Scene Lighting
Everyday after dark lighting scheme
Night time pathway lighting
Event lighting scenes (parties, dining, mood settings)
Dusk/Dawn sensor or calculation from latitude & longitude
Motion triggered lights (i.e. front porch, backyard, interior rooms)
Vacation schedule after dark lighting scheme with auto-variance
    Home Entertainment (A/V) Controls
Room lighting: control drapes, blinds, dimmers
Device power up sequence and configuration
Play selection (CD, DVD, VHS, Cable, Satellite, Media PC)
Channel/volume control
DVD/VCR/DVR control (play, pause, stop rewind, fast forward, eject)
    General control
        Single control –simplified (macro commands)
Remote programming control from the Internet (e.g. TIVO or other DVR)
Home HVAC Controls
Heating and cooling based on single/multiple internal thermostats
Set Heating/Cooling temperature targets via program
Control HVAC mode (Auto, Heating, Cooling, Off)
Ceiling fan controls
Send status on demand or periodic reports
Monitor pool/spa water temperature
Control window shades to lower room temperatureSecurity
        Surveillance Cameras
Stationary cameras with video cable plugs into TV or computer webcam
Pan/Tilt/Zoom (PTZ) cameras (hard-wired or wireless)
Continuous recording of video capture on motion detection
Remote viewing from the Internet (live stream or capture files)
    Miscellaneous
Sprinkler controls (rain detection shut off)
Integrate custom systems (requires computer interface)
Appliance controls (electrical water heater, other)
Integrated Pool/Spa controls
It is apparent, you will need to do some research, not only potential products but, doing some price research. We will go into the above in more detail at a later time.

Now you do not have to implement everything, Maybe even one item is all you need. Now that we have that out of the way, Lets go back to the discussion.  Last time we said that home automation is basically being able to turn something on or off remotely. Let us refine that a little bit. We actually need something to be controlled, a device to do the controlling, and an interface to oversee the controlling.

Something to be controlled can be digital such as on or off like a light switch. That is pretty easy. In some cases though, we need to be able to adjust a device to a certain level and that is analog sort of like measuring with a ruler, light dimmer switch or even with a thermometer.

We need a way to control devices based on a pre-setup instructions which may or many not be dependent on the time of day or feedback from sensor devices,  We can send a signal to turn on an electronic switch as if you just simply turned on light switch or we could use an electronic valve like on a water faucet to adjust those things that are analog.  For example you may want to dim or brighten a lamp. We use a stepper motor that can turn in increments in two directions to adjust a light dimmer switch. This would be as if you were turning the knob on the dimmer. Of course you will want a light sensor to get feedback on how the lamp is doing.

 

If you build it yourself, you can use everything from a microcontroller such as the Arduino to a full fledged computer. The system will need to be able to output the current status and let you change it if need be. For a computer you will need to have some kind of web server installed. The Arduino has a simple interface to be able to ouput to the web if the ethernet shield is attached.

 

So now you have remote control via a simple web page. Next time we will spend some time in the big long list at the start of the article.

—————————————-

Have not tested this, so try at your own risk.

 

 

From Hackaday (http://hackaday.io/project/6258) Single chip  usb temperature sensor.
Description
I  (the Hackaday author) created this project because I wanted to learn about PIC microcontrollers and the USB protocol. I also wanted to see how simple I could make a USB device. I’ve gotten it down to two components: a PIC16F1455 microcontroller and the USB connector. The microcontroller acts as a USB serial device and will send the temperature as an ASCII string once per second.
Details

The PIC16F1455 is a relatively new microcontroller that can do USB without an external crystal. It also has internal pull-up resistors for the USB data lines. These things mean no extra hardware is necessary for USB communication.
I needed something useful to send over USB and I noticed that the PIC16F1455 has a Temperature Indicator Module. This peripheral will let you read the operating temperature of the silicon die over the ADC. It’s not terribly accurate, but the silicon die temperature will be about equal to the outside temperature.

I carefully soldered a male USB Type A connector to the PIC16F1455’s Vdd, Vss, D+, and D- pins. Then, using the M-Stack USB Stack from Signal 11, I wrote a program to enumerate the PIC16F1455 as a USB CDC serial device and send the temperature in ADC counts as an ASCII string at 1 Hz.
From the computer side, it’s easy to connect to the USB temperature data logger like any other serial device, parse the incoming strings, and save the data to a file with a timestamp.
The last step is to map the ADC counts to a temperature scale. Microchip has an application note AN1333 with some equations. However, for a constant Vdd, the scale is pretty linear so it’s easiest to record the ADC count at two known temperatures and interpolate between them.

Looks pretty straight forward.

Some code links:

 https://github.com/mogenson/USBTempLogger

 https://github.com/signal11/m-stack
—————————————-

Try this at your own risk.

From the kodi wiki:

Follow this simple procedure:

  1. Open the receiver’s plastic case using a small screw driver. Carefully pry around the case.
  2. Solder the wire to the receiver using the picture below
  • Note: This might damage the casing of the dongle.

1 Color Coded Pinout

Xbox-dvd-pinout thumb.jpg

  • If you’re using a standard USB cable you should just be able to match the colors and solder away, but to be sure check your cable with a continuity tester according to the USB spec provided here.
  1. Red = Positive Power (+5V DC)
  2. White = Data –
  3. Green = Data +
  4. Yellow = Unused
  5. Black = Ground (0V DC)

Normal usb connections:

Pin Name Cable color Description
1 VCC Red +5 VDC
2 D- White Data –
3 D+ Green Data +
4 GND Black Ground

 

2 Lirc Config

/etc/lirc/hardware.conf:

#Chosen Remote Control
REMOTE="None"
REMOTE_MODULES="lirc_atiusb lirc_dev"
REMOTE_DRIVER=""
REMOTE_DEVICE="/dev/lirc0"
REMOTE_SOCKET=""
REMOTE_LIRCD_CONF=""
REMOTE_LIRCD_ARGS="-r"

#Chosen IR Transmitter
TRANSMITTER="None"
TRANSMITTER_MODULES=""
TRANSMITTER_DRIVER=""
TRANSMITTER_DEVICE=""
TRANSMITTER_SOCKET=""
TRANSMITTER_LIRCD_CONF=""
TRANSMITTER_LIRCD_ARGS=""

#Enable lircd
START_LIRCD="true"

#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD="false"

#Try to load appropriate kernel modules
LOAD_MODULES="true"

# Default configuration files for your hardware if any
LIRCMD_CONF="lircd.conf"

#Forcing noninteractive reconfiguration
#If lirc is to be reconfigured by an external application
#that doesn't have a debconf frontend available, the noninteractive
#frontend can be invoked and set to parse REMOTE and TRANSMITTER
#It will then populate all other variables without any user input
#If you would like to configure lirc via standard methods, be sure
#to leave this set to "false"
FORCE_NONINTERACTIVE_RECONFIGURATION="true"
START_LIRCMD=""

/etc/lirc/lircd.conf:


# brand: Microsoft Xbox DVD Receiever (also works with generic)
# remote control: Xbox remote or any remote using RCA DVD player codes

begin remote

name XboxDVDDongle
bits 8
eps 30
aeps 100

one 0 0
zero 0 0
gap 163983
toggle_bit_mask 0x0

begin codes
LEFT 0xA9
UP 0xA6
RIGHT 0xA8
DOWN 0xA7
SELECT 0x0B
1 0xCE
2 0xCD
3 0xCC
4 0xCB
5 0xCA
6 0xC9
7 0xC8
8 0xC7
9 0xC6
0 0xCF
MENU 0xF7
DISPLAY 0xD5
REVERSE 0xE2
FORWARD 0xE3
PLAY 0xEA
PAUSE 0xE6
STOP 0xE0
SKIP- 0xDD
SKIP+ 0xDF
TITLE 0xE5
INFO 0xC3
BACK 0xD8
end codes
end remote

If using the Xbox DVD IR dongle, add this line to the bottom of /etc/modprobe.d/blacklist.conf:

blacklist xpad


3 XERC 

 The Sickmods XERC 2 XE works really well with an HTPC and the Xbox DVD dongle. It handles power-off and power-on via your remote. Here are some installation instructions for that.

—————————————-

This may not work with all calculators. Here is an interesting way to count footsteps and estimate how far you have walked.You need a cheap calculator, some foam or sponge, glue, foil, cellophane tape, and 2 long wires.

Then you will want to make a switch. To do tha, drilll or punch a hole in the sponge for the to the bottom.  Glue the foil to the top and bottom of the sponge.  The two foil pieces should not be touching. Connect the wires separately to each foiled surface.

Open up the calculator and connect each of the other wire ends to the top and bottom contacts of the “equals” aka = button. Put a piece of cellophane tape between the contract so that they do not connect. Close the calculator and make sure everything works normally. you would have to press the switch together for the = sign to work.  Attach the switch to the bottom of the shoe.

Now enter “1 + 1” into the calculator. Start waking and you will see the count begin to rise as you walk. When you are finished walking multiply the steps to the length of your stride and you will have your distanced walked.

—————————————-

Could see servos being used with this.

servohand

—————————————-

Zuupa di trippa. A stomach full of goodness.

SUNP0003

Good day.

Ides of june.

Leave a comment

Chit chat

=======

Thinking of B. B. King as he as sort of a hero to me.

The cable I ordered form china came in a month early.

Time for Mercury to settle down and let things get better.

If If you are coding just to code, consider other opportunities There is a lot more to it than just slinging code unless you are just doing it for your own enjoyment. To be honest, if you go to work for a company you will not be choosing what language you use, My first real job was s a maintenance programmer. They had one programming language I was familiar with, but had to learn a completely new language to do my job. Fortunately, having used several languages, I was able to adapt. Just a grain of salt.

Regretfully downloading mswin 2 in base 1.  Taking forever. Could download and install a linux desktop and or server in a fraction of the time spent.  #MSWindows version 2
Cheap sorter box

 When is the best time to get a free computer? When marriages or couples break apart and when MSWindows users think they need a new machine because the operating system requires beefier hardware. Acquired this old P3 for free from a couple breakup. Wiped the drive and put Linux on it. #mswindows #linux #repurpose #computer

——————————————————

Remember the days of modems and bulletin boards. Nostalgia: an old bbs program. (minus the support files)


COMMON SHARED Car.ret, Car.ret$, Lfeed, Lfeed$, Mod.dem, Console
DECLARE SUB delay (Secs!)
DECLARE SUB Lout (l$, Cr!)
CONST False = 0
CONST True = -1
' ****************************************************************************
' eddiedbbs version 0.00001
' main.loop written by computothought
' some data input routines borrowed from the dumbbs program
' last update 02/06/95
start.program:
GOSUB housekeeping
WHILE NOT done
GOSUB The.main.loop
WEND
GOSUB end.of.job
END
' *****************************************************************************
' Subroutines
' -----------------------------------------------------------------------------
housekeeping:
CLS
CLOSE
done = 0
Cdmask = &H80
Carrier = 0
'Status ports should be Com1 = 3fe and Com2 = 2fe (?f8+6)
Rs232.port = &H3FE: '&H3F8 + 6
Mod.dem = 1
Console = 2
Port$ = "COM1:"
Baud$ = "300,"
Flow$ = "N,8,1": ',DS0"
Minute = 60
Char.wait.time = 4 * Minute
Char.grace.time = 1 * Minute
Lin.length = 40
Q$ = CHR$(34)
Bell$ = CHR$(7)
Car.ret = 13
Car.ret$ = CHR$(Car.ret)
Lfeed = 10
Lfeed$ = CHR$(Lfeed)
' ------------------------------------------------
' select.baud - select the baud rate
Com.spec$ = Port$ + Baud$ + Flow$
' ----------------------------------------------
' open communication lines
OPEN Com.spec$ FOR RANDOM AS #Mod.dem
GOSUB pause
OPEN "scrn:" FOR OUTPUT AS #Console
PRINT
' ---------------------------------------------
' Restart the work log file
OPEN "append", #5, "worklog"
PRINT #5, "Start of job", TIME$, DATE$
CLOSE #5
RETURN
' ------------------------------------------------
' gchar - get a character
Gchar:
Char.timeout = False
Charet = 0
T = TIMER
DO
IF NOT EOF(Mod.dem) THEN
Ceddie$ = INPUT$(1, #Mod.dem)
C = ASC(Ceddie$)
PRINT #Mod.dem, CHR$(C);
IF C <> 8 THEN
PRINT #Console, CHR$(C);
ELSE
PRINT #Console, CHR$(29);
END IF
Charet = 1
END IF
GOSUB Carchek
LOOP UNTIL TIMER > T + Char.wait.time OR Charet = 1 OR Carrier = False
IF TIMER > T + Char.wait.time THEN
a$ = Car.ret$ + Lfeed$ + Bell$ + Bell$
a$ = a$ + "This BBS will hang up if you don't press a key."
CALL Lout(a$, True)
Violation = 2
Char.timeout = True
C = 256
END IF
RETURN
' ----------------------------------------------------
' gline - get a line
Gline:
In.line$ = ""
GOSUB Clear.garbage
DO
GOSUB Gchar
SELECT CASE C
CASE IS > 255, Car.ret
REM
CASE 29, 8
In.line$ = LEFT$(In.line$, LEN(In.line$) - 1)
CASE ELSE
In.line$ = In.line$ + CHR$(C)
END SELECT
LOOP UNTIL LEN(In.line$) > Lin.length OR (C = Car.ret AND LEN(In.line$) > 0) OR C > 255 OR Carrier = False
RETURN
' -------------------------------------------------------------------------
' Dtrlow
Dtrlow:
PRINT #Mod.dem, "ATH0"
GOSUB pause
PRINT #Mod.dem, "ATZ"
GOSUB pause
RETURN
' --------------------------------------------------------------------------
' Dtrhi
Dtrhi:
PRINT #Mod.dem, "ATE0M0S0=1&C1"
GOSUB pause
RETURN
' ----------------------------------------------------------
' file download
file.download:
Dload.item$ = ""
DO WHILE UCASE$(Dload.item$) <> "0"
Usefile$ = "dir.fil"
GOSUB File.display
GOSUB Clear.garbage
GOSUB Gchar
Dload.item$ = UCASE$(CHR$(C))
DO WHILE Dload.item$ <= "Z" AND Dload.item$ >= "A"
CALL Lout("Please open your buffer now, then press any key!", True)
GOSUB File.display
GOSUB Clear.garbage
GOSUB Gchar
Usefile$ = "\ul\dload" + CHR$(C)
GOSUB File.display
CALL Lout("Please close your buffer now, then press any key!", True)
GOSUB Clear.garbage
GOSUB Gchar
LOOP
IF Carrier = False OR Char.timeout THEN EXIT DO
LOOP
RETURN
' ----------------------------------------------------------
' bulletin display
bulletins:
Bullet.item$ = ""
DO WHILE UCASE$(Bullet.item$) <> "Q"
Usefile$ = "poster"
GOSUB File.display
CALL Lout("Enter choice: ", False)
GOSUB Clear.garbage
GOSUB Gchar
Bullet.item$ = UCASE$(CHR$(C))
CALL Lout(" ", True)
DO WHILE C > 48 AND C < 57
Usefile$ = Usefile$ + Bullet.item$
GOSUB File.display
C = 256
LOOP
IF Carrier = False OR Char.timeout THEN EXIT DO
LOOP
RETURN
' ----------------------------------------------------------
' new user routine
New.user:
Usefile$ = "newuser"
GOSUB File.display
CALL Lout("Please enter a unique password: ", False)
GOSUB Gline
CALL Lout("", True)
Pass.in$ = In.line$
CLOSE #4
KILL "userfile.old"
NAME "userfile" AS "userfile.old"
OPEN "O", #6, "userfile"
Status = 4
PRINT #6, Q$; Log.name$; Q$; ","; Q$; Pass.in$; Q$; ","; Status; ","; Q$; Time.in$; Q$
CLOSE #6
OPEN "I", #7, "userfile.old"
OPEN "A", #8, "userfile"
DO WHILE NOT EOF(7)
INPUT #7, a$, B$, C, D$
PRINT #8, Q$; a$; Q$; ","; Q$; B$; Q$; ","; C; ","; Q$; D$; Q$
IF a$ = "END" THEN EXIT DO
LOOP
CLOSE #7
CLOSE #8
RETURN
' ---------------------------------------------------------
' file.display
File.display:
OPEN "I", #3, Usefile$
WHILE NOT EOF(3)
LINE INPUT #3, data.in$
CALL Lout(data.in$, True)
WEND
CLOSE #3
RETURN
' =========================================================
' The main Loop
'
' This is where the 'BBS' actually begins.
'
The.main.loop:
Restart:
VIEW PRINT
GOSUB Dtrlow
GOSUB Dtrhi
CLS
PRINT
LOCATE 2, 30: PRINT "eddied BBS version 0.001"
PRINT
Wait.for.ring:
DO
C = 256
LOCATE 3, 30
PRINT DATE$; " "; TIME$
LOCATE 4, 30
PRINT "Rs232:"; INP(Rs232.port)
GOSUB Carchek
LOOP UNTIL Carrier
' -----------------------------------------------------
' start
Mainloop:
VIEW PRINT 6 TO 25
GOSUB Clear.garbage
PRINT
' -----------------------------------------------------
' header
Usefile$ = "prelog"
GOSUB File.display
' -----------------------------------------------------
' logon
logon:
Time.in$ = TIME$
Legal = False
CALL Lout("Please enter your name: ", False)
GOSUB Gline
Log.name$ = In.line$
CALL Lout("", True)
CLOSE #4
OPEN "I", #4, "userfile"
DO WHILE NOT EOF(4)
INPUT #4, Name.in$, Pass.in$, Status, Start$
IF UCASE$(Name.in$) = UCASE$(Log.name$) OR Name.in$ = "END" THEN EXIT DO
LOOP
IF Name.in$ = "END" THEN
GOSUB New.user
ELSE
FOR xdummy = 1 TO 3
CALL Lout(" password: ", False)
GOSUB Gline
Pass.word$ = ""
Pass.word$ = In.line$
CALL Lout("", True)
IF Pass.word$ = Pass.in$ THEN
EXIT FOR
ELSEIF ((Pass.word$ <> Pass.in$) AND (xdummy > 3)) THEN
violate = 1
GOTO Logoff
END IF
NEXT xdummy
END IF
CLOSE #4
' -----------------------------------------------------
' main
menu.item$ = ""
DO WHILE UCASE$(menu.item$) <> "G"
Usefile$ = "post2"
GOSUB File.display
CALL Lout(" ", True)
CALL Lout("Your choice: ", False)
GOSUB Clear.garbage
GOSUB Gchar
menu.item$ = UCASE$(CHR$(C))
CALL Lout(" ", True)
SELECT CASE menu.item$
CASE "D"
GOSUB file.download
CASE "B"
GOSUB bulletins
CASE "G"
violate = 0
END SELECT
IF Carrier = False OR Char.timeout THEN EXIT DO
LOOP
' -----------------------------------------------------
' footer
Usefile$ = "epilog"
GOSUB File.display
' -----------------------------------------------------
' pause
pause:
FOR x = 1 TO 4000
NEXT x
RETURN
' -----------------------------------------------------
' logoff
Logoff:
OPEN "append", #5, "worklog"
PRINT #5, Name.in$, Pass.word$, Time.in$, TIME$, violate
CLOSE #5
a$ = "Logging off"
CALL Lout(a$, True)
a$ = "+++"
CALL Lout(a$, True)
T = TIMER
DO
LOOP UNTIL TIMER > 4 + T
PRINT "Turning DTR low"
GOSUB Dtrlow
CALL delay(2)
PRINT "Bringing DTR high"
GOSUB Dtrhi
CALL delay(2)
RETURN
' ------------------------------------------------------
Carchek:
CC = (INP(Rs232.port) AND Cdmask)
IF CC = 128 THEN
Carrier = True
ELSE
Carrier = False
END IF
RETURN
' ------------------------------------------------------
Clear.garbage:
IF NOT EOF(1) THEN
DO
Ceddie$ = INPUT$(1, #Mod.dem)
LOOP UNTIL EOF(Mod.dem)
END IF
RETURN
' ------------------------------------------------------
end.of.job:
OPEN "append", #5, "worklog"
PRINT #5, "End of use", TIME$, DATE$
CLOSE #5
CLOSE
RETURN
' ===========================================================================

SUB delay (Secs)
' ------------------------------------------------
' delay - wait so many seconds
delay (Secs):
T1 = TIMER
DO
LOOP UNTIL TIMER > 40 + T1
END SUB

SUB flush (Time)
' ----------------------------------------------------
' flush - flush buffer
T = TIMER
DO
IF NOT EOF(Mod.dem) THEN
Dummy$ = INPUT$(LOF(Mod.dem), #Mod.dem)
END IF
LOOP UNTIL TIMER > T + Time
END SUB

SUB Lout (l$, Cr)
' ---------------------------------------------------
' lout - line out
FOR j = 1 TO LEN(l$)
G = ASC(MID$(l$, j, 1))
PRINT #Mod.dem, CHR$(G);
PRINT #Console, CHR$(G);
NEXT j
IF Cr THEN
PRINT #Mod.dem, Car.ret$; Lfeed$
PRINT #Console, Car.ret$;
END IF
END SUB

——————————————————

From Wikipedia:

Pulse-width modulation (PWM), or pulse-duration modulation (PDM), is a technique used to encode a message into a pulsing signal. It is a type of modulation. Although this modulation technique can be used to encode information for transmission, its main use is to allow the control of the power supplied to electrical devices, especially to inertial loads such as motors. In addition, PWM is one of the two principal algorithms used in photovoltaic solar battery chargers,[1] the other being MPPT.

The average value of voltage (and current) fed to the load is controlled by turning the switch between supply and load on and off at a fast rate. The longer the switch is on compared to the off periods, the higher the total power supplied to the load.

The PWM switching frequency has to be much higher than what would affect the load (the device that uses the power), which is to say that the resultant waveform perceived by the load must be as smooth as possible. Typically switching has to be done several times a minute in an electric stove, 120 Hz in a lamp dimmer, from few kilohertz (kHz) to tens of kHz for a motor drive and well into the tens or hundreds of kHz in audio amplifiers and computer power supplies.

The term duty cycle describes the proportion of ‘on’ time to the regular interval or ‘period’ of time; a low duty cycle corresponds to low power, because the power is off for most of the time. Duty cycle is expressed in percent, 100% being fully on.

The main advantage of PWM is that power loss in the switching devices is very low. When a switch is off there is practically no current, and when it is on and power is being transferred to the load, there is almost no voltage drop across the switch. Power loss, being the product of voltage and current, is thus in both cases close to zero. PWM also works well with digital controls, which, because of their on/off nature, can easily set the needed duty cycle.

PWM has also been used in certain communication systems where its duty cycle has been used to convey information over a communications channel.

 

Most micro controllers have pwm pins on board, but you can easily generate or simulate pwm in software for systems without pwm pins. First you do not see the “1” and then you see more of it. Code compiled with freebasic fbc -lang qb [filename]


 cls
for x = 1 to 1000
    for y =1 to (1000 - x)
        locate 1,1
        ?" ";
    next y
    for a = 1 to x
        locate 1,1
        ?"1";
    next a
next x
?

end 

Here is another way using an actual led connected to the parallel port. Emu;ates the idea of the lights dimming and getting brighter.

out 888,0  turns all lights off

out 888,255  turns all lights on


cls
for x = 1 to 50

    for y =1 to x
        locate 1,1
        rem ?"1";
        out 888,255
        for z = 1 to 500000
        next z
    next y
    for a = 1 to 50 -x
        locate 1,1
        rem ?" ";
        out 888,0
        for z = 1 to 500000
        next z
    next a
next x
out 888,0

or


cls
for x = 1 to 1000
    for y =1 to (1000 - x)
        locate 1,1
        rem ?" ";
        out 888, 0
    next y
    for a = 1 to x
         locate 1,1
         rem ?"1";
         out 888,255
    next a
next x
out 888,0 

——————————————————

Oldie, but goodie: Batch file to slowly print out a text file. Perfect for a quickie teleprompter.

; then
file="$1"
else
file="-"
fi

cat "$file" | while read c ; do
echo "$c"
sleep .5
done

——————————————————

If this is a duplicate, oopss.

 

Screenshot from 2013-12-08 15:29:59.png

 

Screenshot from 2013-12-08 15:33:39.png

 

 

Screenshot from 2013-12-08 15:50:30.png

Love MPD. It is both a music player and an internet radio player. You can install this on a really old machine or a new arm based linux device. Just add an amp and  speakers and you have a new age stereo that can be controlled remotely..
Make your directories where you want your music to be and then copy them there if they are not already there. Now to inbstall the basic software. You have the program itself (mpd)and a command line player to test it.(mpc)

$sudo apt-get install mpd mpc.

Sure sure your stero and or speakers are attached to the sound card and they work. Now to test it. We will do it with a radio station if you do not have any music to t4est with.

$ mpc add http://relay3.slayradio.org:8000/
adding: http://relay3.slayradio.org:8000/

$ mpc play
You should hear the radio station out of your speakers now.

Now let’s edit the config file for file location and to allow the server to be accesed from other systems. Warning this is not secure, as your better off sshing into the machine to control it.

$ sudo vim /etc/mpd.con
Change the directory where you files are (uncomment  the line also
# Files and directories #######################################################
#
# This setting controls the top directory which MPD will search to discover the
# available audio files and add them to the daemon’s online database. This
# setting defaults to the XDG directory, otherwise the music directory will be
# be disabled and audio files will only be accepted over ipc socket (using
# file:// protocol) or streaming files over an accepted protocol.
#
# music_directory               “/var/lib/mpd/music”

If you want to access the machine remotely you will need to change the hostname to the nmae of the michine, Warning: people will be albe to telnet into the machine unless you password protect the system.
#
# This setting sets the address for the daemon to listen on. Careful attention
# should be paid if this is assigned to anything other then the default, any.
# This setting can deny access to control of the daemon. Choose any if you want
# to have mpd listen on every address
#
# For network
# bind_to_address               “localhost”

Permissions:

# Permissions #################################################################
#
# If this setting is set, MPD will require password authorization. The password
# can setting can be specified multiple times for different password profiles.
#
#password                        “password@read,add,control,admin”
#
# This setting specifies the permissions a user has who has not yet logged in.
#
#default_permissions             “read,add,control,admin”
#
###############################################################################

There are other settings, but I will let you check that out your selves..

Now to access the system form other machines. There is a client for about every system known to man. You can check them out yourself at:

Screenshot from 2013-12-08 16:25:45.png
http://mpd.wikia.com/wiki/Clients

To add a radio station, you most likely have to have a url.

Have fun

——————————————————

Couple of cartoons:

Screenshot from 2015-06-06 07:36:40

Screenshot from 2015-06-04 02:20:52

Screenshot from 2015-05-29 14:47:37

Screenshot from 2015-06-01 00:47:39

Screenshot from 2015-05-29 15:27:06

Screenshot from 2015-06-01 01:12:30

 

——-Screenshot from 2015-05-31 17:55:25———————————————–

Put your tax dollars back to work.  Obsolete #computers could be a boon for #school #science departments.There are three kinds of ports usually on microcontrollers. Digital, Serial and pwm. From computers, the digital is the parallel port. you can also use the parallel port for pwm using only a few lines of code say in even qbasic. Lastly the serial port can be adapted to interface all kinds of sensors such as for temperature. That obsolete  computer can be made  into a sous vide machine in a matter of minutes, Control leds, an rc car, or even be used as a part of a home automation project. The i486 make a nice multiple rocket launcher. It’s your tax dollars, so use it wisely. #retrocomputing

FJCVOUYGZUAFO2L.MEDIUM

P000-256-267-481-f1016

P000-256-267-481-f1016

——————————————————

Screenshot from 2015-06-08 12:33:46

Not ours but some nice files for instruction in electronics.
wget https://dl.dropboxusercontent.com/u/103847327/Lab%201.pdf
wget https://dl.dropboxusercontent.com/u/103847327/Lab%202.pdf

wget https://dl.dropboxusercontent.com/u/103847327/Lab%202%20part%202.pdf
wget https://dl.dropboxusercontent.com/u/103847327/Lab%203.pdf
wget https://dl.dropboxusercontent.com/u/103847327/Lab%204.pdf
wget https://dl.dropboxusercontent.com/u/103847327/Lab%205.pdf
wget https://dl.dropboxusercontent.com/u/103847327/Lab%206.pdf
wget https://dl.dropboxusercontent.com/u/103847327/Lab%207.pdf

wget https://dl.dropboxusercontent.com/u/103847327/Lab%208.pdf

wget https://dl.dropboxusercontent.com/u/103847327/Lab%209.pdf
wget https://dl.dropboxusercontent.com/u/103847327/Lab%2010.pdf

wget https://dl.dropboxusercontent.com/u/103847327/Lab%202%20part%202.pdf

——————————————————

PC oscilloscope or how to save yourself hundreds of dollars before you buy an oscilloscope. Pull that old PC out of the closet and make it an oscilloscope: Could of copied everything here like I usually do, but most people know how to use a hyperlink.  http://www.instructables.com/id/Simple-PC-oscilliscope/

——————————————————

Minimal to use the Arduino as a web server and that is already in a sketch
that you can use. You need to edit the code so it will work in your network. 
 
</pre>
<pre><code class="hljs cpp"><span class="hljs-preprocessor">#include <SPI.h>
#include <Ethernet.h>

/******************** ETHERNET SETTINGS ********************/

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x85, 0xD9 };  //physical mac address
byte ip[] = { 192, 168, 0, 112 };                   // ip in lan
byte subnet[] = { 255, 255, 255, 0 };              //subnet mask
byte gateway[] = { 192, 168, 0, 1 };              // default gateway
EthernetServer server(80);                       //server port

void setup()
{
Ethernet.begin(mac,ip,gateway,subnet);     // initialize Ethernet device
server.begin();                             // start to listen for clients
pinMode(8, INPUT);                         // input pin for switch
}

void loop()
{
EthernetClient client = server.available();   // look for the client

/* a place for the code*/

delay(1);      // giving time to receive the data

/*
The following line is important because it will stop the client
and look for the new connection in the next iteration i.e
EthernetClient client = server.available();
*/
client.stop();
}</span></code></pre>
<pre></pre>
<pre><code class="hljs cpp"><span class="hljs-preprocessor">

 

 
 
Now for the code to do what you want the Arduino to do. Almost looks like
a type of cgi script. This goes in the middle of the script. Definitely 
some errors in this case.

 

client.println(<span class="hljs-string">"HTTP/1.1 200 OK"</span>);
client.println(<span class="hljs-string">"Content-Type: text/html"</span>);
client.println(<span class="hljs-string">"Connnection: close"</span>);
client.println();

<span class="hljs-comment">/*
This portion is the webpage which will be
sent to client web browser one can use html , javascript
and another web markup language to make particular layout
*/</span>

client.println(<span class="hljs-string">"<!DOCTYPE html>"</span>);    <span class="hljs-comment">//web page is made using html</span>
client.println(<span class="hljs-string">"<html>"</span>);
client.println(<span class="hljs-string">"<head>"</span>);
client.println(<span class="hljs-string">"<title>Ethernet Tutorial</title>"</span>);
client.println(<span class="hljs-string">"<meta http-equiv=\"refresh\" content=\"1\">"</span>);

<span class="hljs-comment">/*
The above line is used to refresh the page in every 1 second
This will be sent to the browser as the following HTML code:
<meta http-equiv="refresh" content="1">
content = 1 sec i.e assign time for refresh
*/</span>

client.println(<span class="hljs-string">"</head>"</span>);
client.println(<span class="hljs-string">"<body>"</span>);
client.println(<span class="hljs-string">"<h1>A Webserver Tutorial </h1>"</span>);
client.println(<span class="hljs-string">"<h2>Observing State Of Switch</h2>"</span>);

client.print(<span class="hljs-string">"<h2>Switch is:  </2>"</span>);

<span class="hljs-keyword">if</span> (digitalRead(<span class="hljs-number">8</span>))
{
client.println(<span class="hljs-string">"<h3>ON</h3>"</span>);
}
<span class="hljs-keyword">else</span>
{
client.println(<span class="hljs-string">"<h3>OFF</h3>"</span>);
}

client.println(<span class="hljs-string">"</body>"</span>);
client.println(<span class="hljs-string">"</html>"</span>);</pre>
<pre><code class="hljs cpp">

 

This what the code might look like all put back together and have made 
a few changes.

 

</pre>
<pre><code class="hljs cpp">#include <SPI.h>
#include <Ethernet.h>
/******************** ETHERNET SETTINGS ********************/

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x85, 0xD9 };  //physical mac address
byte ip[] = { 192, 168, 1, 112 };                   // ip in lan
byte subnet[] = { 255, 255, 255, 0 };              //subnet mask
byte gateway[] = { 192, 168, 1, 1 };              // default gateway
EthernetServer server(80);                       //server port

void setup()
{
Ethernet.begin(mac,ip,gateway,subnet);     // initialize Ethernet device
server.begin();                             // start to listen for clients
pinMode(8, INPUT);                         // input pin for switch
}

void loop()
{
EthernetClient client = server.available();   // look for the client

// send a standard http response header

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connnection: close");
client.println();

/*
This portion is the webpage which will be
sent to client web browser one can use html , javascript
and another web markup language to make particular layout
*/

client.println("<!DOCTYPE html>");    //web page is made using html
client.println("<html>");
client.println("<head>");
client.println("<title>Ethernet Tutorial</title>");
client.println("<meta http-equiv=\"refresh\" content=\"1\">");

/*
The above line is used to refresh the page in every 1 second
This will be sent to the browser as the following HTML code:
<meta http-equiv="refresh" content="1">
content = 1 sec i.e assign time for refresh
*/

client.println("</head>");
client.println("<body>");
client.println("<h1>A Webserver Tutorial </h1>");
client.println("<hr>");

client.println("<h2>Observing State Of Switch</h2>");
client.println("<center>");
client.println("<table border='1'>");
client.println("<td>");
client.println("<tr>");
client.println("<td>");
client.print("<h2>Switch is:  </h2>");
client.println("</td>");
client.println("<td>");
if (digitalRead(8))
{
client.println("<h3>ON</h3>");
}
e</code><code class="hljs cpp"><code class="hljs cpp"> </code><code class="hljs cpp"> </code><code class="hljs cpp">---</code>lse
{
client.println("<h3>OFF</h3>");
}
client.println("</td>");
client.println("</tr>");
client.println("</table>");
client.println("</center>");
client.println("</body>");
client.println("</html>");

delay(1);      // giving time to receive the data

/*
The following line is important because it will stop the client
and look for the new connection in the next iteration i.e
EthernetClient client = server.available();
*/
client.stop();

}</code></pre>
<pre><code class="hljs cpp">

——————————————————

Ideas on holding several Raspberry Pi’s together,

 

or put them into individually stackable cases

——————————————————

Compatible to computer networks.

What is the ESP8266?

The ESP8266, is a cheap WiFi module which you can address using the UART protocol. It’s been featured on Hackaday and other DIY electronics blogs very recently, and lots of DIY electronics tinkers are very excited at the doors this module opens for their projects. The module is:
Small Footprint
Easy to integrate with (using UART)
Takes care of all other overheads for getting WiFi up-and-running (TCP/IP Stack etc…)
. . . and, perhaps more importantly than all the other factors, very cheap – it can be purchased from China in a quantity of one for less than £4 !

There are no market equivalents for the DIY community – the XBee has been a popular choice for adding WiFi to DIY projects up until now, but the ESP8266 module is close to one tenth the price making it easily accessible for all types of low cost applications.

The ESP8266 is the name of the chip it’s self manufactured by a company called Espressif, but it is sold in modules manufactured in China which look as seen below,

The module can be addressed using a series of AT commands. These are simple commands sent UART at 115200 baud. For example, once the module is wired up, you can send the command

AT+RST will perform a software reset on the device. AT+CWLAPwill displat all of the currently available WiFi networks etc. – simple enough!
How do I set up the ESP8266 Module?

Here is a simple pin-out for the module (the pin numbers are defined in the table
and relate to the image):

Pin Number Pin Function Pin Number Pin Function
1 RX 5 GPIO2
2 VCC 6 CH_PD
3 GPIO0 7 GND
4 RST 8 TX

Note: Under normal operation Pin 6 (CH_PD) should be tied high (3V3) to ensure correct operation

As such, you can easily wire up the module to an Arduino or just a simple USB to serial converter and start sending AT commands (Remember: RX on the module joins to TX on the connection device and vice versa!).
What are the drawbacks of using this module?

As we’ve seen above, this is shaping up to be a very good value-for-money solution for adding WiFi capabilities to DIY projects, so what are the limitations.
The module is rather ‘power thirsty’. The current supplied via USB to an Arduino is barely enough to power this module. Other websites have recommended that you should have easily 1A available, but I have not measured this myself. This makes integrating the module slightly more tricky as a second, separate voltage regulator is required and it also rules out any battery powered projects.
It is temperamental – I’ve had a chance to play with this module, and although it works most of the time, all of the sample code I have found provides far from a solid solution – there are plenty of quirks to using it.

Code examples:  https://github.com/esp8266/Arduino/archive/esp8266-sdk-1.0.zip

Adding support for the esp8266 in the arduino ide 1.6.4 Depending on the speed of your internet connection how long it will take

Installing with Boards Manager

Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. We have packages available for Windows, Mac OS, and Linux (32 and 64 bit). The 1.7.3 version did not have this option.

  • Install Arduino 1.6.4 from the Arduino website.
  • Start Arduino and open Perferences window.
  • Enter http://arduino.esp8266.com/package_esp8266com_index.json into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas.
  • Open Boards Manager from Tools > Board menu and install esp8266 platform (and don’t forget to select your ESP8266 board from Tools > Board menu after installation).

 

 

——————————————————

Something cool. (Salt helps it cool faster),

Good day

2b | !2b Shakesperean math?

Leave a comment

Chit chat

======

Screenshot - 06172014 - 10:01:35 AM


Just finished running the slackeware 14.1 update on my old Pentium 1 586. The wordpress update is taking a bit longer. Have tried to install all the old CL favorites like sc, but my favorite install is Freebasic. Have been able to port so much of my old software. Need to copy all my new batch files especially the page scrapers. Also installed is the web server for use as a doc server. When I did the install I did it with a pxeboot to a directory on the web server and the internet did the rest. Might be interesting if I could get iscsi or aoe to work and make the local hd unneeded. That is for another day. Using a compact flash for the drive now. So quiet. Also made an atx to at power cable so I could run the system on battery if needed. What does ‘obsolete’ mean? have dnsmasq working on it.
 If you are coding just to code, consider other opportunities There is a lot more to it than just slinging code unless you are just doing it for your own enjoyment. To be honest, if you go to work for a company you will not be choosing what language you use, My first real job was s a maintenance programmer. They had one programming language I was familiar with, but had to learn a completely new language to do my job. Fortunately, having used several languages, I was able to adapt. Just a grain of salt. .
Remember #caldera , #SCO and etc. Guess they forgot they gave out their source code. #linux
#IBM
You heard of B.C. This is B. A.  Before #Arduino. #hardware
Sous vide #arduino prototype
Normally we avoid posting anything Microsoft, but today we are going to make an exception.
When is the best time to get a free computer? When marriages or couples break apart and when MSWindows users think they need a new machine because the operating system requires beefier hardware. Acquired this old P3 for free from a couple breakup. Wiped the drive and put Linux on it.

Developed this simple wedding registry using Visual Basic on a i386 in the early days of gui for my then employer. Got me and interview to work with IT but accepted another companies offer.. Need to go back and code again.

Early dual cpu (aka dual core) system that was set up as a router. A collectors item.

—————————————-

Ever go somewhere and you need to have several systems be able to access their network, but they say all you cn have is one Ipaddress. An Ipaddress is like a phone number for a computer.  You can only have one per system under normal circumstances. Here with an extra system, we will show you how to do this.

A multitude of reasons exist as to why one would want to build a custom router vs. suffer with the performance, reliability issues, and limitations of an off-the-shelf solution. In the spirit of keeping this post short, I won’t launch into a long diatribe on the pros and cons of each here, but I have plenty of thoughts on this, so if you are interested, just ask.

What we are about to do is configure an incredibly fast and stable router/gateway solution for your home/office in about 15 minutes. (Note: This post assumes you already have your machine loaded up with a fresh copy of Ubuntu 14.04 or an equivalent and you have the two needed NICs installed.) This is not a firewall.

First, let’s make three initial assumptions:

eth0 is the public interface (the Cable/DSL modem is attached to this NIC)
eth1 is the private interface (your switch is connected to this NIC)
All of the client computers, servers, WAPs, etc. are connected to the switch

Let’s get started with the configuration. Set your timer and type quickly! 🙂

1.) Configure the network interfaces
You may need to make sure for older systems that plug and play os is enabled. Change the “address”, “netmask”, and “broadcast” values to match your internal network preferences. They must be different from the host aka wan network.

sudo nano -w /etc/network/interfaces
# The external WAN interface (eth0) public
allow-hotplug eth0
iface eth0 inet dhcp

# The internal LAN interface (eth1) private
allow-hotplug eth1
iface eth1 inet static
address 10.1.10.1
netmask 255.255.255.0
network 10.1.10.0
broadcast 10.1.10.255

2. Install and configure DNSmasq
DNSmasq is DNS forwarder and DHCP server. Change “domain” to the FQDN of your network and “dhcp-range” to the desired range of DHCP addresses you would like your router to serve out to clients.

sudo apt-get install dnsmasq

nano -w /etc/dnsmasq.conf
interface=eth1
listen-address=127.0.0.1
domain=home.andreimatei.com
0dhcp-range=10.1.10.100,10.1.10.110,12h

3.) Enable IP Forwarding
Uncomment the following line:

sudo nano -w /etc/sysctl.conf
net.ipv4.ip_forward=1

4.) Configure iptables
We create a file called /etc/iptables.rules and put this rule set inside of it.  As an example, this set includes allowing tcp traffic in from the outside world on port 222 (I run SSH on this alternate port) and also port-forwards tcp port 50,000 to an internal machine with the ip of 10,1,10.3 Use this as a guide for your own rules.

Note that when you do this access to the system will be locked down amd ssh not work. Infact a ping to the system will be ignored.

sudo nano -w /etc/iptables.rules

*nat
-A PREROUTING -i eth0 -p tcp -m tcp –dport 50000 -j DNAT –to-destination 192.168.0.3:50000
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT

*filter
-A INPUT -i lo -j ACCEPT
-A INPUT -m state –state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp –dport 222 -j ACCEPT
-A INPUT -i eth0 -j DROP
-A FORWARD -i eth0 -p tcp -m tcp –dport 50000 -m state –state NEW -j ACCEPT
COMMIT

5.) Activate your iptables rules

iptables-restore < /etc/iptables.rules

6.) Ensure iptables rules start on boot
Insert the following line into your /etc/network/interfaces file right underneath “iface lo inet loopback”

nano -w /etc/network/interfaces
pre-up iptables-restore < /etc/iptables.rules

7.) Reboot and Verify
That’s it! After a reboot, you should now have a very basic Linux Router/Gateway for your network.

router:~$ sudo nano -w /etc/iptables.rules
[sudo] password for eddie:

router:~$ sudo iptables-restore < /etc/iptables.rules

router:~$ sudo nano -w /etc/network/interfaces

router:~$ sudo reboot

router:~$
Broadcast message from router
(/dev/pts/0) at 8:44 …

The system is going down for reboot NOW!
Connection to 192.168.1.102 closed by remote host.

Connection to 192.168.1.102 closed.

You should be able to use your router now.

NOte: you should be able to do this with most any distro, but using different commands. Wnat to try this with a pentium 1 and Slackware. Did not have time to trying before putting this article out.

oedt01:~$ ssh 192.168.1.102
192.168.1.102’s password:
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-53-generic i686)

* Documentation:  https://help.ubuntu.com/
Last login: Fri May 29 07:39:02 2015

router:~$ cd /etc

router:/etc$ sudo vim  dnsmasq.conf
[sudo] password for eddie:

router:/etc$ sudo vim /etc/network/interfaces

router:/etc$ sudo vim  dnsmasq.conf

router:/etc$ sudo service dnsmasq restart

* Restarting DNS forwarder and DHCP server dnsmasq                      [ OK ]
router:/etc$ sudo service dnsmasq sttus
Usage: /etc/init.d/dnsmasq {start|stop|restart|force-reload|dump-stats|status}
router:/etc$ sudo service dnsmasq status
* Checking DNS forwarder and DHCP server dnsmasq                                * (running)

Connect to the client side. We used a tablet and crossover adapter to check dnsmasq. You could use a network switch also.

Note: if you get a usb to ethernet adapter, you can make a mice little Raspberry Pi router. You could also use a wireless card for the lan, but that requires a bit more security,

You may also want to setup webmin to make managing the router easier.

—————————————-

It is not required, but installing webmin can make managing the router easier.

router:/etc$ cd

router:~$ wget http://prdownloads.sourceforge.net/webadmin/webmin_1.750_all.deb
–2015-05-29 08:15:22–  http://prdownloads.sourceforge.net/webadmin/webmin_1.750_all.deb
Resolving prdownloads.sourceforge.net (prdownloads.sourceforge.net)… 216.34.181.59
Connecting to prdownloads.sourceforge.net (prdownloads.sourceforge.net)|216.34.181.59|:80… connected.
HTTP request sent, awaiting response… 301 Moved Permanently
Location: http://downloads.sourceforge.net/project/webadmin/webmin/1.750/webmin_1.750_all.deb [following]
–2015-05-29 08:15:22–  http://downloads.sourceforge.net/project/webadmin/webmin/1.750/webmin_1.750_all.deb
Resolving downloads.sourceforge.net (downloads.sourceforge.net)… 216.34.181.59
Connecting to downloads.sourceforge.net (downloads.sourceforge.net)|216.34.181.59|:80… connected.
HTTP request sent, awaiting response… 302 Found
Location: http://hivelocity.dl.sourceforge.net/project/webadmin/webmin/1.750/webmin_1.750_all.deb [following]
–2015-05-29 08:15:22–  http://hivelocity.dl.sourceforge.net/project/webadmin/webmin/1.750/webmin_1.750_all.deb
Resolving hivelocity.dl.sourceforge.net (hivelocity.dl.sourceforge.net)… 74.50.101.106
Connecting to hivelocity.dl.sourceforge.net (hivelocity.dl.sourceforge.net)|74.50.101.106|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 26195366 (25M) [application/octet-stream]
Saving to: ‘webmin_1.750_all.deb’

100%[======================================>] 26,195,366   586KB/s   in 42s

2015-05-29 08:16:04 (614 KB/s) – ‘webmin_1.750_all.deb’ saved [26195366/26195366]

router:~$ sudo dpkg -i webmin_1.750_all.debSelecting previously unselected package webmin.
(Reading database … 57184 files and directories currently installed.)
Preparing to unpack webmin_1.750_all.deb …
Unpacking webmin (1.750) …
dpkg: dependency problems prevent configuration of webmin:
webmin depends on libnet-ssleay-perl; however:
Package libnet-ssleay-perl is not installed.
webmin depends on libauthen-pam-perl; however:
Package libauthen-pam-perl is not installed.
webmin depends on libio-pty-perl; however:
Package libio-pty-perl is not installed.
webmin depends on apt-show-versions; however:
Package apt-show-versions is not installed.

dpkg: error processing package webmin (–install):
dependency problems – leaving unconfigured
Processing triggers for ureadahead (0.100.0-16) …
Errors were encountered while processing:
webmin

There will probably be an error. There is an easy fix.

router:~$ sudo apt-get upgrade -f
Reading package lists… Done
Building dependency tree
Reading state information… Done
Correcting dependencies… Done
Calculating upgrade… Done
The following NEW packages will be installed:
apt-show-versions libapt-pkg-perl libauthen-pam-perl libio-pty-perl
libnet-ssleay-perl
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 425 kB of archives.
After this operation, 1,752 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main libnet-ssleay-perl i386 1.58-1 [242 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/universe libauthen-pam-perl i386 0.16-2build3 [27.8 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty/main libio-pty-perl i386 1:1.08-1build4 [36.7 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ trusty/main libapt-pkg-perl i386 0.1.29build1 [84.5 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu/ trusty/universe apt-show-versions all 0.22.3 [33.9 kB]
Fetched 425 kB in 1s (226 kB/s)
Selecting previously unselected package libnet-ssleay-perl.
(Reading database … 82053 files and directories currently installed.)
Preparing to unpack …/libnet-ssleay-perl_1.58-1_i386.deb …
Unpacking libnet-ssleay-perl (1.58-1) …
Selecting previously unselected package libauthen-pam-perl.
Preparing to unpack …/libauthen-pam-perl_0.16-2build3_i386.deb …
Unpacking libauthen-pam-perl (0.16-2build3) …
Selecting previously unselected package libio-pty-perl.
Preparing to unpack …/libio-pty-perl_1%3a1.08-1build4_i386.deb …
Unpacking libio-pty-perl (1:1.08-1build4) …
Selecting previously unselected package libapt-pkg-perl.
Preparing to unpack …/libapt-pkg-perl_0.1.29build1_i386.deb …
Unpacking libapt-pkg-perl (0.1.29build1) …
Selecting previously unselected package apt-show-versions.
Preparing to unpack …/apt-show-versions_0.22.3_all.deb …
Unpacking apt-show-versions (0.22.3) …
Processing triggers for man-db (2.6.7.1-1ubuntu1) …
Setting up libnet-ssleay-perl (1.58-1) …
Setting up libauthen-pam-perl (0.16-2build3) …
Setting up libio-pty-perl (1:1.08-1build4) …
Setting up libapt-pkg-perl (0.1.29build1) …
Setting up apt-show-versions (0.22.3) …
** initializing cache. This may take a while **
Setting up webmin (1.750) …
Webmin install complete. You can now login to https://router:10000/
as root with your root password, or as any user who can use sudo
to run commands as root.
Processing triggers for ureadahead (0.100.0-16) …

—————————————-

How can I compile a simple C or C++ program on Linux operating systems using bash Terminal application?

Tutorial details

Difficulty: easy
Root privileges No
Requirements GNU C/C++ compiler
Estimated completion time 10m

GNU C and C++ compiler collection
Development tools
Development libraries
IDE or text editor to write programs

Part 1: Install C/C++ compiler and related tools

To compile a C or C++ program on any Linux distro such as Ubuntu, Red Hat, Fedora, Debian and other Linux distro you need to install:

>Fedora, Redhat, Centos, Or Scientific linux:

# yum groupinstall ‘Development Tools’

>Debian, Ubuntu, or Mint

$ sudo apt-get update
$ sudo apt-get install build-essential manpages-dev

To verify the install, type the following commands to display the version number and location of the compiler on Linux:

$ whereis gcc
$ which gcc
$ gcc –version

Sample outputs:

$ whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc /usr/bin/X11/gcc

$ whereis g++
g++: /usr/bin/g++ /usr/bin/X11/g++

$ gcc –version
gcc (Debian 4.7.2-5) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc
gcc: fatal error: no input files
compilation terminated.
$

Part 2:  GNU C compiler on Linux. Create a file called demo.c using a text editor such as vim or nano

#include<stdio.h>
/* demo.c: My first C program on a Linux
*/
int main(void) {
printf(“Hello! This is a test program.\n”);
return 0;
}

Save as demo.c

How do I compile the program on Linux?

Use any one of the following syntax to compile the program called demo.c:

$ cc program-source-code.c -o executable-file-name

OR

$ gcc program-source-code.c -o executable-file-name

In this example, compile demo.c, enter:
$ cc demo.c -o demo

If there is no error in your code or C program then the compiler will successfully create an executable file called demo in the current directory, otherwise you need fix the code. To verify this, type:

$ ls -al demo*
-rwxr-xr-x 1 eddie eddie 4884 May 31 20:35 demo
-rw-r–r– 1 eddie eddie  149 May 31 20:35 demo.c

How do I run or execute the program called demo on Linux? Just simply type the the program name

$ ./demo

OR

$ /path/to/demo

$ ./demo
Hello! This is a test program.

Part 3: GNU C++ compiler on Linux

Create a program called demo.cpp as follows:

#include “iostream”
// demo2.C – Sample C++ program
int main(void) {
std::cout << “Hello! This is a C++ program.\n”;
return 0;
}

To compile this program, enter:

$ g++ demo.cpp -o demo

To run this program, type: ./demo

$ ./demo
Hello! This is a C++ program.

Part 4: More information.
How do I generate optimized code on a Linux machine?

The syntax is as follows C compiler:
cc -O input.c -o executable
The syntax is as follows C++ compiler:
g++ -O -Wall input.C -o executable
How do I compile a C program that uses math functions?

The syntax is as follows when need pass the -lm option with gcc to link with the math libraries:
cc myth1.c -o executable -lm
How do I compile a C++ program that uses Xlib graphics functions?

The syntax is as follows when need pass the -lX11 option with gcc to link with the Xlib libraries:
g++ fireworks.C -o executable -lX11
How do I compile a program with multiple source files?

The syntax is as follows if the source code is in several files (such as light.c, sky.c, fireworks.c):
cc light.c sky.c fireworks.c -o executable
C++ syntax is as follows if the source code is in several files:
g++ ac.C bc.C file3.C -o my-program-name

See gcc(1) : Linux and Unix man page for more information.

$ man gcc

—————————————-

Yet another weather picture grabber and the the picture is converted to ascii.

#!/bin/bash

#Set variables
DOWNLOAD_DIR=/tmp/weather/
WEATHER_GIF=http://archive.wfaa.com/weather/images/core/animated-loops/comp/880×495/new_tarrant.gif

COUNTER=0

#check for  download directory
if [ ! -d “$DOWNLOAD_DIR” ]; then
mkdir -p $DOWNLOAD_DIR
fi

#remove old files
rm  $DOWNLOAD_DIR/*gif
rm  $DOWNLOAD_DIR/*.png
rm  $DOWNLOAD_DIR/*.txt

#get weather gif
wget $WEATHER_GIF -O “${DOWNLOAD_DIR}map.gif”

#extract gif to png
convert -coalesce “${DOWNLOAD_DIR}/map.gif” “${DOWNLOAD_DIR}/map.png”

#convert images to text
for i in $DOWNLOAD_DIR/map-*; do
img2txt -f utf8 -W 100 -H 30 $i > $i.txt
done

#display images
while [ $COUNTER -lt 5 ] ; do
for i in $DOWNLOAD_DIR/map-*.txt; do
printf ’33[1;1H’
cat $i
sleep 0.5
done
let COUNTER=COUNTER+1
done

—————————————-

 

There are many parts to home automation but the main need is to be able to turn something on or off. Without that the rest is meaningless. Let us start with a simple light switch that you can control manually. The off position we will call zero and the on position we will call the one state.

 

Of course the purpose of home automation is for you not to have to manually turn off or on a switch. So we can get an electronic part known as a switching transistor to do the job for us with the help of a computing device that we can program. These diagrams are way over simplified to make things simpler. We could ask the computer to turn off all the leds with a command like out 888,0 and if any leds were on, they would immediately turn off.

 

The again, we could issue a command to turn them all on with out 888,255

 

Then you would want to turn them off and on individually also. Then you would either write some code or have a per-written program to do it for you and have appliances turn on or off at your will. Of course once you have your programming arranged, you can control the leds or any kind of home appliance or anything else at will. That is when interesting things can start happening if you want them to.

That ends part one.  Next time we will dig a little deeper using sensors such as a computer based thermometer as part of the mix.

—————————————-

In the real world. you probably would not be building any electronics. You could purchase network based control boxes. Most of the devices would be controlled by the time of day or manually controlled like a remote stereo system.

 

Many single sensors are cause and affect such as a garage door opener where the system waits for the detection of the controller and the proper security sequence. or you could have multiple sensors that workindependently but cuase the same affect such as a fire alarm or a security system

Screenshot from 2015-06-02 05:39:29

But let use get a bit more sophisticated. you could add a variety of sensors, but the most common might be the temperature sensor for control of your heating cooling system. The same idea could probably be adapted to a sous vide cooking system.

Now things have become a bit more complicated with additional sensors and control devices required. Also requires more complicated programming. You can see where systems can become very expensive.

We have only scratched the surface when it comes to sensors. That is part 2 for now,

—————————————-

Lovescope and monthly (use at your own risk)

####################################
# Horoscope Grabber
#
#===============================
# Assignments
# ——————————–
datafile=”rawcnn.txt”
let “flag = 0”
# end assignments
#=================================
#
# Get data file
#———————————
end=$(echo $1 | tr ‘[:lower:]’ ‘[:upper:]’)
elinks -dump “http://www.horoscopes.co.uk/$1/Love-Horoscope.php&#8221; > $datafile
#=================================
#
# Extract and display data
#———————————
while read line
do fdata[$a]=$line
echo $line | grep -q “Love Horoscope”
if [ $? -eq 0 ]; then
# header
clear
let “flag = 1”
fi
if [ $flag -eq 1 ]; then
echo $line | grep -q $end
if [ $? -eq 0 ]; then
let “flag = 0”
else
echo $line | grep -q “IMG”
if [ $? -eq 0 ]; then
let “response = donothing”
else
echo $line | sed ‘s/\[.*\]//’
fi
fi
fi
let “a += 1″
done < $datafile
# footer
echo ———————————————
echo $1
#===================================
# End.
####################################

####################################
# Horoscope Grabber
#
#===============================
# Assignments
# ——————————–
datafile=”rawcnn.txt”
let “flag = 0”
# end assignments
#=================================
#
# Get data file
#———————————
elinks -dump “http://www.horoscopes.co.uk/$1/Monthly-Horoscope.php&#8221; > $datafile
#=================================
#
# Extract and display data
#———————————
while read line
do fdata[$a]=$line
echo $line | grep -q “Monthly Horoscope”
if [ $? -eq 0 ]; then
# header
clear
let “flag = 1”
fi
if [ $flag -eq 1 ]; then
echo $line | grep -q “Horoscopes”
if [ $? -eq 0 ]; then
let “flag = 0”
else
echo $line | grep -q “IMG”
if [ $? -eq 0 ]; then
let “response = donothing”
else
echo $line | sed ‘s/\[.*\]//’
fi
fi
fi
let “a += 1”
done < $datafile
# footer
echo ———————————————
echo
#===================================
# End.
####################################

—————————————-

Sweet potato pie before topping.

yampie

Good day.