HDD Disk + Arduino – не очень то работает.

Работает, но не очень.

Драйвер для двигателей.

Источник: http://theamateurprogrammer.blogspot.com/2014/02/revitalizing-old-hard-drive-motors.html

int phase1 = 9;
int phase2 = 6;
int phase3 = 5;

int A = 9;
int B = 6;
int C = 5;

int led = 13;

unsigned long stepLength = 40000;
int minStepLength = 7000; //1400
int steps = 50;

void setup() {
  pinMode(led, OUTPUT);  
  pinMode(phase1, OUTPUT);
  pinMode(phase2, OUTPUT);
  pinMode(phase3, OUTPUT);
  analogWrite(led, LOW);
}

void loop() {
  switchStep(1);
  switchStep(2);
  switchStep(3);
 
  if(stepLength > minStepLength)
  {
    stepLength = stepLength - steps;
  } else {
    // set the minimum pulse length
    stepLength=minStepLength;
  }
 
  if (stepLength < 39950) {
    analogWrite(led, HIGH);   // second gear
    steps = 300;
  }
   
  if (stepLength < 20000) {
    analogWrite(led, LOW);      // third gear
    steps = 50;
  }

  if (stepLength < 3000) {
    analogWrite(led, HIGH);      // fourth gear
    steps = 2;
  }
}


// CB, AB, AC, BC, BA, CA

void switchStep(int stage)
{
  int PWM = 64;
 
  switch(stage)
  {
  case 1:
    analogWrite(phase1, PWM); // 100 ok
    analogWrite(phase2, 0);
    analogWrite(phase3, 0);
    myDelay(stepLength);
    break;
   
  case 2:
    analogWrite(phase1, 0);
    analogWrite(phase2, PWM);
    analogWrite(phase3, 0);
    myDelay(stepLength);
    break;
   
  default:
    analogWrite(phase1, 0);
    analogWrite(phase2, 0);
    analogWrite(phase3, PWM);
    myDelay(stepLength);
    break;
  }  


}

void myDelay(unsigned long p) {
if (p > 16380) {
  delay (p/1000);
  } else {
  delayMicroseconds(p);
  }
}

Просмотр последних снимков со спутников NOAA

#!/usr/bin/python

import os, syslog,io
import pygame, re
import time
import pywapi
import string
import requests
import datetime

try:
    # Python2
    from urllib2 import urlopen
except ImportError:
    # Python3
    from urllib.request import urlopen

#!/usr/bin/python

import os, syslog
import pygame
import time
import pywapi
import string
import os
import io


BLACK = (0,0,0)
WHITE = (255,255,255)
GREEN = (0,255,0)
RED = (255,0,0)
BLUE = (0,0,255)

SCREEN_WIDTH = 320
SCREEN_HEIGHT = 240

os.putenv('SDL_FBDEV', '/dev/fb1')
os.putenv('SDL_MOUSEDRV', 'TSLIB')
os.putenv('SDL_MOUSEDEV', '/dev/input/touchscreen')

pygame.display.init()
size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
screen = pygame.display.set_mode(size, pygame.FULLSCREEN)
screen.fill((0, 0, 0))        
pygame.font.init()
pygame.display.update()
pygame.mouse.set_visible(False)
fontpath = pygame.font.match_font('dejavusansmono')

font = pygame.font.Font(fontpath, 20)
fontSm = pygame.font.Font(fontpath, 18)

font_big = pygame.font.Font(None, 50)
font_small = pygame.font.Font(None,30)

ok = True

while ok:
    url = 'http://sat.pajero4x4.ru/?image=last'
    try:
            data = requests.get(url=url)
    except:
        print "Error Request"
        time.sleep(10)     
    else:  
        if data.status_code == 200:
            if re.search('jpg#',data.text):
                noaa = data.text.split("\n")
                f,d = noaa[-1].split("#")
                image_url = "http://sat.pajero4x4.ru/NOAA/" + f
                try:
                    image_str = urlopen(image_url).read()
                except HTTPError as e:
                    print "Error url..."
                else:  
                    image_file = io.BytesIO(image_str)
                    logo = pygame.image.load(image_file).convert()
                    logo = pygame.transform.scale(logo,( SCREEN_WIDTH, SCREEN_HEIGHT))
                    screen.blit(logo, (0, 0))
                    text = font_small.render('%s'%d, True,RED)
                    screen.blit(text,(5,220))
                    pygame.display.update()
        else:
            print "Error"

    time.sleep(10)
    print "Reload"
    print(datetime.datetime.now())