• Categories
    • Unread
    • Recent
    • Popular
    • Users
    • Groups
    • Register
    • Login
    1. Home
    2. Scuzz
    3. Posts
    Offline
    • Profile
    • Following 0
    • Followers 3
    • Topics 91
    • Posts 375
    • Groups 1

    Posts

    Recent
    • RE: [Python] Twitter controlled LEDs

      I have got a working version of the twitter bot.
      Every 60 seconds it will grab the latest tweet to me and if it contains a html colour code it will change my LEDs to that colour.

      Python

      from twython import Twython, TwythonError
      import serial, time, re
      
      ser = serial.Serial('COM3', 9600, timeout=2)
      
      regex = re.compile('(#[a-f0-9]{6}|#[a-f0-9]{3})', re.IGNORECASE)
      
      api_key = ""
      api_secret = ""
      access_token = ""
      access_secret = ""
      tweetID = 0
      
      twitter = Twython(api_key, api_secret, access_token, access_secret)
      
      while True:
          try:
              search_results = twitter.search(q = 'to:joshuarickers', count = 1, since_id = tweetID)
          except TwythonError as e:
              print(e)
      
          print('Tweet: ', search_results['statuses'][0]['text']) 
      
          if re.search(regex, search_results['statuses'][0]['text']):
              colour = re.search(regex, search_results['statuses'][0]['text']).group()
              print('Colour :', colour)
              print(ser.readline())
              ser.write(bytes(colour, 'ascii'))
      
          time.sleep(60)
      

      Arduino

      #include "FastLED.h"
      
      #define NUM_LEDS 50
      
      #define DATA_PIN 11
      #define CLOCK_PIN 13
      
      CRGB leds[NUM_LEDS];
      String htmlColour;
      long number;
      
      void setup() { 
        Serial.begin(9600);
        FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
      }
      
      void loop(){
      
        if (Serial.available() > 0){
          htmlColour = Serial.readStringUntil('\n');
          Serial.read();
          number = strtol( &htmlColour[1], NULL, 16);
          Serial.println(number);
        }
        
        for(int i = 0; i < NUM_LEDS; i++) {
          leds[i] = number;
          leds[i].maximizeBrightness();
        }
        FastLED.show();
      }
      
      posted in Development and Coding
      ScuzzS
      Scuzz
    • RE: What are you listening to today?

      https://www.youtube.com/watch?v=dFh71_ftxLE

      posted in The lounge
      ScuzzS
      Scuzz
    • RE: [Python] Twitter controlled LEDs

      Here is some of the twitter code i had from the other night.
      This code returns the latest tweet to my account.

      from twython import Twython, TwythonError
      import time
      
      api_key = ""
      api_secret = ""
      access_token = ""
      access_secret = ""
      tweetID = 0
      
      twitter = Twython(api_key, api_secret, access_token, access_secret)
      
      try:
          search_results = twitter.search(q = 'to:joshuarickers', count = 1, since_id = tweetID)
      except TwythonError as e:
          print(e)
      
      print(search_results['statuses'][0]['text'])
      
      posted in Development and Coding
      ScuzzS
      Scuzz
    • RE: [Python] Twitter controlled LEDs

      I struggled to get Python to send string to the Arduino because i didnt realise the had to be encoded into bytes. Once i realised this I was able to pass on some test colours with the following code.

      import serial
      
      ser = serial.Serial('COM3', 9600, timeout=2)
      ser.readline()
      ser.write(bytes('#00CED1', 'ascii'))
      print(ser.readline())
      ser.write(bytes('#8B008B', 'ascii'))
      print(ser.readline())
      ser.write(bytes('#FFFF00', 'ascii'))
      print(ser.readline())
      

      One thing i did notice is that I had to delay some of the communication with some readline() as it would just return an empty string.

      posted in Development and Coding
      ScuzzS
      Scuzz
    • RE: [Python] Twitter controlled LEDs

      Arduino

      Since the previous post @Almost has helped me realise that the decimal value of a hex value can be used in place of a hex value. I should have figured that out pretty easy but the documentation for FastLED and my understanding of HTML Colour codes and Hex Colour codes got me all confused. It did click after lying in bed for about 30 minutes trying to figure the situation out.

      I didn’t have time yesterday to put it into practice and to see if FastLED could accept a decimal value. It can and now instead if setting the LED colours with 0x0000FF I can just use the value 255 instead.

      @Almost also mentioned the strtol() function which will convert a string to a long. This basically solves all my issues.
      The code below shows that when i send a string of "#0000FF\n" via serial to my Arduino it will convert the "0000FF" into a long integer, 0000FF being 255. This value is then past to the array of LEDs which in turn turns all the LEDs blue.

      #include "FastLED.h"
      
      #define NUM_LEDS 50
      
      #define DATA_PIN 11
      #define CLOCK_PIN 13
      
      CRGB leds[NUM_LEDS];
      String htmlColour;
      long number;
      
      void setup() { 
        Serial.begin(9600);
        FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
      }
      
      void loop(){
      
        if (Serial.available() > 0){
          htmlColour = Serial.readStringUntil('\n');
          number = strtol( &htmlColour[1], NULL, 16);
          Serial.println(number);
        }
        
        for(int i = 0; i < NUM_LEDS; i++) {
          leds[i] = number;
          leds[i].maximizeBrightness();
        }
        FastLED.show();
      }
      
      posted in Development and Coding
      ScuzzS
      Scuzz
    • RE: Hockey? Golf? Gaming Night [Friday, August 14th]

      I’m on call so no pub for me. I should be available.

      posted in Gaming
      ScuzzS
      Scuzz
    • [Python] Twitter controlled LEDs

      Before I started messing around trying to get Hyperion working with my Raspberry Pi I had my LEDs set up to work with my Arduino. During this time I had an idea about controlling the colour from a tweet.
      I remembered seeing a blog post a long time ago about someone doing something similar with tweets and thought it might be fun to try.

      That was a while back and I have only just started to actually do something about it.

      The Process

      The whole process should look something like this:

      • Someone sends a tweet to my account “@JoshuaRickers #FF0000”
      • My twitter bot written in Python will pick up that tweet
      • Send the html colour code to my Arduino
      • Arduino changes LED colours

      Simple enough?

      Python Regex

      I don’t know if regex hates me more or if I hate regex more. After a while of playing around and searching Google I think I have come up with the correct regex for this little project.

      /(#[a-f0-9]{6}|#[a-f0-9]{3})/i

      Python does not have anything built in to handle the usual regular expression syntax so you have to use a slightly modified regex with the re module.

      import re
      p = re.compile('(#[a-f0-9]{6}|#[a-f0-9]{3})', re.IGNORECASE)
      test_str = "@joshuarickers #FFFfff"
      m = re.search(p, test_str).group()
      print(m)
      

      This is a basic test to see if the regex actually works and for me to figure out how to use it in Python. I had only previously used regex when trying to code that IMDB plugin for NodeBB, using JavaScript. This is slightly different.

      From the above code m == #FFFfff which is exactly what I want. This will then be passed to my Arduino for it to works its magic.

      posted in Development and Coding python twitter led arduino
      ScuzzS
      Scuzz
    • RE: Who is upgrading to Windows 10?

      Well I have finally managed to get it installing. I had to completely remove my dual boot partitions , remove grub and fix my MBR.

      As soon as i did this it booted into the upgrade process when my laptop rebooted.

      Anyone having issues upgrading while having a dual boot then that is most likely the issue.

      posted in General Computing
      ScuzzS
      Scuzz
    • RE: Who is upgrading to Windows 10?

      Has anyone had any success with upgrading from Windows 7 to Windows 10?

      I have had my laptop download and upgrade about 6 times now all for it to reboot back into Windows 7.

      The update error is c1900101 20017. I receive this when upgrading from the notification and from the tool that @Schamper posted.

      The only thing i havent tried is creating an install disk/usb, that may be my last resort.

      posted in General Computing
      ScuzzS
      Scuzz
    • RE: Who is upgrading to Windows 10?

      If some of you are still waiting for the update to actually run you can try running and in elevated CMD

      wuauclt.exe /updatenow

      As soon as ran that command i had the upgrade window pop up.

      “preparing for upgrade”

      posted in General Computing
      ScuzzS
      Scuzz
    • RE: Who is upgrading to Windows 10?

      Today is the 29th, the release date for Windows 10.
      I have read that not everyone will be able to download windows 10 today as Microsoft are doing a slow release. Hopefully it will not be as slow as some of the tech blogs have said.

      I am currently only running the upgrade on my work laptop to see how the whole process works and to see if it is worth upgrading my home desktop.

      If you are upgrading and are unsure if the download process is actually running, there is a folder located in on your C Drive - C:\$Windows.~BT. If this folder is there then you are in the process of downloading Windows 10.

      Total size of the update is around 6.5GB.

      posted in General Computing
      ScuzzS
      Scuzz
    • RE: [nodebb-theme-classic] BitBangers Classic Theme

      Upgraded for the latest version of NodeBB, v0.7.2

      @Firelad it should be ok for you now.

      posted in Development and Coding
      ScuzzS
      Scuzz
    • RE: Virtual Desktops

      alt+tab and Win+tab is different to Win+(number)

      alt+tabbing through 10 windows is effort, wouldnt 4 finger sliding be the same amount of effort?

      One keyboard short cut or one gesture would be a lot faster.

      posted in General Computing
      ScuzzS
      Scuzz
    • RE: Virtual Desktops

      @Almost I can see the efficiency with the swipe and keyboard short cuts but the same could be done with just one screen. Using Win + (number) to maximise or minimise the program that is relevant to (number) in the task bar.

      posted in General Computing
      ScuzzS
      Scuzz
    • Virtual Desktops

      I have been reading about some of the new features in Windows 10 and I have read that virtual desktops are going to be a thing in Windows 10. I know they have been a part of Linux OS’s for a while. Are they also in OSX?

      Do you guys make use of them?

      Whenever I have used Linux for my desktop I have found them quite useless. It seemed to be more effort to switch to the correct desktop than just clicking the item on the task bar.

      It seems that a lot of people are excited about them but I dont really know why.

      posted in General Computing
      ScuzzS
      Scuzz
    • RE: Hiya there!

      @SCP-Angelic Hey, welcome to BitBangers. I was pretty sure Sylphannia had joined here but cant seem to find the account. I may be confused with someone else though.

      posted in Introductions
      ScuzzS
      Scuzz
    • RE: Who is upgrading to Windows 10?

      @Almost He is foreign, what else would you expect?

      posted in General Computing
      ScuzzS
      Scuzz
    • Who is upgrading to Windows 10?

      Windows 10 is due out at the end of the month. Those of you who run a Windows based computer, who will be upgrading?

      This is the perfect moment for me to upgrade to an SSD with a clean Windows 10 install,.

      posted in General Computing windows 10 upgrade
      ScuzzS
      Scuzz
    • RE: Game Night (Terraria? Dinosaurs in Minecraft?) [Friday, July 3rd]

      was this another failed attempt?

      posted in Gaming
      ScuzzS
      Scuzz
    • RE: Show off your phone

      Do you think the side menu takes up too much space on screen?
      I like to have a decent amount of apps displayed, 5 is my preferred row length. 3 is too few imo. But i suppose that’s why you have the categories?

      I have a feeling it would look and feel better on something with a larger screen.

      posted in Tech
      ScuzzS
      Scuzz
    • 1
    • 2
    • 3
    • 4
    • 5
    • 18
    • 19
    • 3 / 19