Monthly Archives: April 2018

Getting started with Arduino cryptography

via SparkFun: Commerce Blog

I’m always looking for a way to teach difficult concepts in classroom settings, especially if I can lean on the confluence of my love of tinkering and my love of puzzles.

alt text

An Enigma code machine

I bought a new house several months ago and it has a garage. I don’t want to buy new garage remotes (that would be much too easy) when I can build them out of parts that SparkFun sells everyday. The thought occurred to me that it would be fun to do in encrypted wireless using an XBee module; that way I could program not only commands for the garage door, but for lights and the front door and anything else that I can put on electronic control.

alt text

A basic substitution cipher

At the heart of the way we do business on the web is RSA encryption. RSA is a brilliant and complicated way to encrypt information using large prime numbers. As many of us can remember from algebra, the prime factorization of large numbers can be very difficult. RSA relies on using this within a framework of modular exponentiation and totient equations to pass information safely.

All of this is very effective for secure banking transactions, but probably not necessary for turning on lights at my house.

alt text

alt text

An early puzzle box I built with BASIC STAMP.

When I started thinking about this problem I did, however, take some of the way we think about RSA encryption and applied it to a simple Arduino program. Here is how I thought about my problem:

  1. Using an Arduino base station to store an array of three-digit numbers.

  2. Use the random function in Arduino to generate a random number, store it in a variable and subtract it from a random place in the array.

  3. Pass the place in the array and difference generated to a client device as values separated by commas.

  4. If the client device has the matching array as the base station, it will subtract the number it received from the specific place in the array, and pass the difference back to the base station.

  5. The base station will add the answer it receives from the requesting device to the number stored in the variable. If the sum of these two things is equivalent to the place in the array that the base station has been working with, it will grant access to the client device.

Let’s look at this in action!

My array = {103,147,171,199}

My random number generated = 59

My random pace in the array = 2

So: 171-59 = 112

I pass to a device requesting access (2,112).

If that device has the same array stored on it as my key array on the base station, it will subtract what it received from the specified place in the array.

 171-112 = 59

I send back to the base station a request (like the character “r”) and 59, so the transmission would be (r,59).

The base station then adds the number it receives - if that number and the number it sent are equivalent to the value in that place in the array, it grants the request. In my Arduino code I have set it up so that our lights are red LEDs.

Here’s some Arduino code; test it with the serial terminal.

///////////////////////

int keys[]=

{117,161,173,187,199};

int arryPos=0;

char request;

int arrayPos;

int subtractNum;

int returnVal;

int red=0;

int blue=0;

int green=0;

void setup()

{
Serial.begin(9600);



pinMode(13,OUTPUT);

pinMode(12,OUTPUT);

pinMode(11,OUTPUT);

pinMode(10,OUTPUT);

pinMode(9,OUTPUT);


}


void loop()

{


//subtractNum=10;




  if(Serial.available()!=0)

  {

request= Serial.read();

 digitalWrite(13, HIGH);

if(request=='a')

{

arrayPos=(random(0,4));

subtractNum=(random(1,100));



delay(10);

Serial.print(arrayPos);

Serial.print(",");

Serial.println(keys[arrayPos]-subtractNum);


}

if(request=='r')

{

 returnVal=Serial.parseInt();

Serial.print("array val =");

Serial.println(keys[arrayPos]);

Serial.print(returnVal + keys[arrayPos]-subtractNum);//subtractNum=10+ x = 117

delay(50);

if(returnVal + keys[arrayPos]-subtractNum==keys[arrayPos])

{

digitalWrite(9,HIGH);

delay(350);

digitalWrite(9,LOW);

delay(350);

digitalWrite(9,HIGH);

delay(350);

digitalWrite(9,LOW);

delay(350);

digitalWrite(9,HIGH);

delay(350);

digitalWrite(9,LOW);

delay(350);

}

}


}

digitalWrite(13,LOW);

}

//////////////////////

When you get this code loaded to the Arduino, you can then follow these steps:

  1. Open a terminal in Arduino and send your board the character “a.”

alt text

  1. You will receive two values separated by commas. The first value is the place in the array, and the second value is what to subtract from the value in the array.

alt text

  1. Return the character “r,” separated from the difference with a comma.

alt text

  1. You should get a return equivalent to the array value and the sum of the two values. If you have an LED connected to pin 9, it should blink.

alt text

The next step is creating a device to send the serial commands. This could be another Arduino, and this is where it really opens up. The client could be a traditional remote with push-button function, or a keypad, or even a fingerprint reader.

I think the classroom applications of this project are particularly interesting. The idea I had was to let students “tune into” the traffic being passed back and forth, and try to figure out the key array based on the behavior of the packets – seems like a great hacking/cryptography prompt.

I am adding code to my GitHub page, so you are welcome to dig around there and take this further. Happy hacking!

comments | comment feed

How servo motors work and how to control servos using Arduino

via Dangerous Prototypes

p-Arduino-and-PCA9685-PWM-Servo-Driver-600

Dejan Nedelkovski over at HowToMechatronics shared detailed tutorial on how servo motors work and how to control servos using Arduino and PCA9685 PWM driver:

There are many types of servo motors and their main feature is the ability to precisely control the position of their shaft. A servo motor is a closed-loop system that uses position feedback to control its motion and final position.
In industrial type servo motors the position feedback sensor is usually a high precision encoder, while in the smaller RC or hobby servos the position sensor is usually a simple potentiometer. The actual position captured by these devices is fed back to the error detector where it is compared to the target position. Then according to the error the controller corrects the actual position of the motor to match with the target position.
In this tutorial we will take a detailed look at the hobby servo motors. We will explain how these servos work and how to control them using Arduino.

More details at HowToMechatronics.

Check out the video after the break.

 

First Lithographically Produced Home Made IC Announced

via hardware – Hackaday

It is now six decades since the first prototypes of practical integrated circuits were produced. We are used to other technological inventions from the 1950s having passed down the food chain to the point at which they no longer require the budget of a huge company or a national government to achieve, but somehow producing an integrated circuit has remained out of reach. It’s the preserve of the Big Boys, move on, there’s nothing to see here.

Happily for us there exists a dedicated band of experimenters keen to break that six-decade dearth of home-made ICs. And now one of them, [Sam Zeloof], has made an announcement on Twitter that he has succeeded in making a dual differential amplifier IC using a fully lithographic process in his lab. We’ve seen [Jeri Ellsworth] create transistors and integrated circuits a few years ago and he is at pains to credit her work, but her interconnects were not created lithographically, instead being created with conductive epoxy.

For now, all we have is a Twitter announcement, a promise of a write-up to come, and full details of the lead-up to this momentous event on [Sam]’s blog. He describes both UV lithography using a converted DLP projector and electron beam lithography using his electron microscope, as well as sputtering to deposit aluminium for on-chip interconnects. We’ve had an eye on his work for a while, though his progress has been impressively quick given that he only started amassing everything in 2016. We look forward to greater things from this particular garage.

#FreePCB via Twitter to 2 random RTs

via Dangerous Prototypes

IRToy-600x369

Every Tuesday we give away two coupons for the free PCB drawer via Twitter. This post was announced on Twitter, and in 24 hours we’ll send coupon codes to two random retweeters. Don’t forget there’s free PCBs three times a every week:

  • Hate Twitter and Facebook? Free PCB Sunday is the classic PCB giveaway. Catch it every Sunday, right here on the blog
  • Tweet-a-PCB Tuesday. Follow us and get boards in 144 characters or less
  • Facebook PCB Friday. Free PCBs will be your friend for the weekend

Some stuff:

  • Yes, we’ll mail it anywhere in the world!
  • Check out how we mail PCBs worldwide video.
  • We’ll contact you via Twitter with a coupon code for the PCB drawer.
  • Limit one PCB per address per month please.
  • Like everything else on this site, PCBs are offered without warranty.

We try to stagger free PCB posts so every time zone has a chance to participate, but the best way to see it first is to subscribe to the RSS feed, follow us on Twitter, or like us on Facebook.

A look back at CTC Valencia Fair 2018

via Arduino Blog

On April 18th, a team from Arduino Education made it to the museum Ciudad de las Artes y las Ciencias in Valencia to participate in the CTC Valencia Fair. A total of 1,200 students (out of 1,500 people in attendance) participated in the five-hour-long event where the students exhibited what they had been producing over the last couple of months.

CTC, the Creative Technologies in the Classroom initiative

CTC started as a project in the region of Castilla La Mancha in Spain. I was asked what kind of process could be implemented in order to bring teachers and school up to speed with new educational technologies. Back then, in 2012, I had been teaching students from many different disciplines, mostly at the university level: interaction design, medicine, engineering, product design, mathematics, multimedia, fine arts… I had also been working with upper secondary school teachers from Spain, Argentina, and Sweden in the creation of small curriculums introducing interactive technologies a part of more transversal teaching in subjects like science and design.

When asked by the people in charge at the regional centre for educators in Castilla La Mancha, I suggested a quick iterative design process that began with a collective survey to teachers in 25 schools and followed by a curriculum suggestion on topics that they considered relevant. The most complex aspect in this process was how to design interventions in the way of implementing this programme so that I could incorporate the teachers’ as well as the students’ opinions and debug the content as we went. CTC has over 25 different mid-size experiments designed to help a class get acquainted to work in a project-based learning methodology through an iterative process.

The first CTC fair brought together over 400 students from all over Castilla La Mancha that presented 100-plus projects. Almost five years later, we have witnessed yet another incredible fair with very nice results, only this time in Valencia.

What has changed

CTC now includes experiments with wireless technology, accelerometers, capacitive sensing, motors, lights, and other interesting tricks, thanks to using the Arduino 101 board that comes with BLE, an IMU, and some other goodies. Students are introduced to programming using Processing and the Arduino IDE. But not everything is coding, given our pedagogic approach, they learn how to work in groups, search for technical information, organize time, and present their results…

On the Arduino side, we have jumped from having a good old WordPress site to enable communication between the students, to a full-fledged platform that is being augmented with new materials and courses on a yearly basis. The content works for both the classic IDE and the more modern Create IDE. At the same time, we have implemented a hotline where teachers can ask questions directly to Arduino’s support specialists. Of course, there is a forum just for teachers to talk to one another and the Arduino forum still supporting them; but we have learned that teachers like one-to-one communication because each school is somehow different in terms of equipment, network facilities, classrooms and policies, and social environment–teachers, students, and their families.

We have learned about complex deployments; for example, in Valencia there is a special Linux distribution called Lliurex that we had to hack in order to get the IDE running properly. During a previous project in Andalucia, teachers had no administration password to the computers! Well, we did figure things out and got the project to work. So big kudos to our support team that had to get out the hacker hoodie and code a clever solution!

Also, for the CTC webinars we make on a bi-weekly basis, we have changed our online seminar backend to have a much more efficient one. Now our calls allow full interaction with the participants that can be invited to talk and share screens when needed instead of simply having a chat line back.

Valencia is cool, isn’t it?

We had a CTC fair at the Ciudad de las Artes y las Ciencias, a museum by Santiago Calatrava in the shape of a huge boat put upside-down. There are fountains surrounding the building, the weather was amazing (remember I am coming from Sweden, where we just had the worst winter in 10 years, so anything over 15°C is good at this point), the organizers from CEFIRE (the teacher organization in Valencia’s region) made a great preparation of the location, schools arrived on time, the show went fine-great-FABULOUS… so yes, Valencia is cool, and the so was the CTC fair.

On stage we could see almost 30 projects being presented by the students, while we conducted a two and a half-hour livecast for those interested in seeing the projects from anywhere in the world. We held 15 interviews, but unfortunately we couldn’t show everything happening, considering that there were a more than 150 projects on display!

The following video is a summary of livestream from the museum; for your benefit, we have chosen some highlights of the broadcast I conducted throughout the day.

The interviews were conducted in Spanish, which is another reason for the summary; but if you are interested in the actual interviews, check out the following video.

Some seriously nice projects

I cannot stop being surprised by the amount of creativity students show when making projects. Even if I attend an average of five events of this nature per year, I keep on finding projects that make an impression in me. Students are always challenging any pre-conceptions I might have about what could be done with something as simple as an Arduino board. The one thing teachers keep on saying again and again is that it was them, the students, that pushed the process forward, that once they got started with the course, it was hard not to get carried away by the students initiative. The role of the teachers is playing the realist, trying to make sure the projects come to an end. That said, here some of the things I saw while walking around in the fair.

Probably the most impressive project I came across was a model of the Hogwart’s castle inspired by the Harry Potter movies. It took the students four months to build the entire project. It was a replica of the castle, so heavy that it needed four people to carry it around. It had dragons flying around one tower, the lights could be turned on and off… there was even a fountain with running water! The whole mode could be controlled via Bluetooth from an Android tablet. In total, the model took three months to construct, the students said, while making the electronics and software work took one month.

On the other side of the spectrum, I could play with a small arm wrestling toy made by a single student that took only 5 hours to build. You can check out the interview with the student in the above-posted videos. While the project seems to be simple, it is clear that the student had become quite knowledgeable in the craft of making projects, since he had figured everything for the project on his own without any external help.

One last project I would like to talk about was a small drawing machine comprised of mechanics from DVD drives that could replicate small drawings (less than 10x10cm big) using a pen. The students explained that it barely worked the night before, but that they finally figured out the calibration process minutes before leaving for the fair. The results, as you can see on the video interviews, are quite remarkable. They can export drawings using the open source program Inkscape in a format (G-code) their machine can understand, this allows them to trace any kind of vectorized drawing and reproduce it with their machine.

There were a lot more projects, take a look at the videos and pictures in this blog post. We will be presenting some others as part of the Arduino Livecast series in the the future. If you want to know more, just subscribe to Arduino’s YouTube channel and you will get weekly notifications on our videos.

Acknowledgements

The CTC Valencia project has been possible thanks to the generous contribution of EduCaixa, the on-site collaboration of the technical body at CEFIRE, the kind support of the regional government of Valencia – the Generalitat -, and the help of our old friend Ultralab.

From everyone involved in the project, big thanks to Ismael and Oscar, who believed in the project and pushed for it. Personally I want to thank Nerea who coordinated the project, and Roxana who was there making it happen from Arduino on a weekly basis; also Carla and Carlos who covered up when needed. Finally to Laura, who worked long evenings on top of everything else to make all of graphics needed for the fair.

At a more technical level, we have a new revision to the look and feel of the CTC project site coming, and it is looking awesome. Marcus, Gabrielle, Luca and everyone working with the UX in Arduino are creating one of the best-looking educational experiences ever. If not only the content is good, but if it feels good and looks good, then the experience will be excellent!

Do you want CTC in your world?

If you want to be part of the CTC initiative, visit Arduino Education’s website, subscribe to the Arduino Education Newsletter [at the bottom of that site], or send us a request for more information via email: ctc.101@arduino.cc.

[Photos by Pablo Ortuño]

Tackling climate change and helping the community

via Raspberry Pi

In today’s guest post, seventh-grade students Evan Callas, Will Ross, Tyler Fallon, and Kyle Fugate share their story of using the Raspberry Pi Oracle Weather Station in their Innovation Lab class, headed by Raspberry Pi Certified Educator Chris Aviles.

Raspberry Pi Certified Educator Chris Aviles Innovation Lab Oracle Weather Station

United Nations Sustainable Goals

The past couple of weeks in our Innovation Lab class, our teacher, Mr Aviles, has challenged us students to design a project that helps solve one of the United Nations Sustainable Goals. We chose Climate Action. Innovation Lab is a class that gives students the opportunity to learn about where the crossroads of technology, the environment, and entrepreneurship meet. Everyone takes their own paths in innovation and learns about the environment using project-based learning.

Raspberry Pi Certified Educator Chris Aviles Innovation Lab Oracle Weather Station

Raspberry Pi Oracle Weather Station

For our climate change challenge, we decided to build a Raspberry Pi Oracle Weather Station. Tackling the issues of climate change in a way that helps our community stood out to us because we knew with the help of this weather station we can send the local data to farmers and fishermen in town. Recent changes in climate have been affecting farmers’ crops. Unexpected rain, heat, and other unusual weather patterns can completely destabilize the natural growth of the plants and destroy their crops altogether. The amount of labour output needed by farmers has also significantly increased, forcing farmers to grow more food on less resources. By using our Raspberry Pi Oracle Weather Station to alert local farmers, they can be more prepared and aware of the weather, leading to better crops and safe boating.

Raspberry Pi Certified Educator Chris Aviles Innovation Lab Oracle Weather Station

Growing teamwork and coding skills

The process of setting up our weather station was fun and simple. Raspberry Pi made the instructions very easy to understand and read, which was very helpful for our team who had little experience in coding or physical computing. We enjoyed working together as a team and were happy to be growing our teamwork skills.

Once we constructed and coded the weather station, we learned that we needed to support the station with PVC pipes. After we completed these steps, we brought the weather station up to the roof of the school and began collecting data. Our information is currently being sent to the Initial State dashboard so that we can share the information with anyone interested. This information will also be recorded and seen by other schools, businesses, and others from around the world who are using the weather station. For example, we can see the weather in countries such as France, Greece and Italy.

Raspberry Pi Certified Educator Chris Aviles Innovation Lab Oracle Weather Station

Raspberry Pi allows us to build these amazing projects that help us to enjoy coding and physical computing in a fun, engaging, and impactful way. We picked climate change because we care about our community and would like to make a substantial contribution to our town, Fair Haven, New Jersey. It is not every day that kids are given these kinds of opportunities, and we are very lucky and grateful to go to a school and learn from a teacher where these opportunities are given to us. Thanks, Mr Aviles!

To see more awesome projects by Mr Avile’s class, you can keep up with him on his blog and follow him on Twitter.

The post Tackling climate change and helping the community appeared first on Raspberry Pi.