Archive

Posts Tagged ‘ahradwani’

Nikon S9900 shot – 23



Subject: The West-Bay by Nikon S9900

In 2016 I bought Nikon Coolpix S9900, I have Nikon D90, and Nikon 7100 both are DX (crop sensor), but S9900 is my first Coolpix (point & shoot) camera from Nikon, I use to have Sony T100. [:. Read more about my cameras and lenses Here .:]

This Shot: In most of the days I am taking the Nikon S9900 camera with me in the car, just to use it and to have photos with it. This is a shot through the car window while driving to work using on hand to hold the camera, in the background we can see the Towers of the West-Bay area, and in the foreground is a Mosque; and I am waiting for a traffic lights to be Green. The original shot was in color and I change it to B/W and crope it before uploaded. I am using Nikon S9900.

…Click Image to Enlarge…
ali radwani ahradwani.com photo photography Nikon coolpix camera s9900 lens
Camera in Hand, F: 5, ISO: 125, Shutter: 1/2000s, Focal-Point: 11mm
Here is the Original Shot ..
ali radwani ahradwani.com photo photography Nikon coolpix camera s9900 lens



::.. To see all my Nikon S9900 Photos Click-Here
::.. To see all my Nikon D7100 Photos Click-Here
::.. To see all my Nikon D90 Photos Click-Here




ali radwani ahradwani.com python projects codeFollow me on Twitter..

By: Ali Radwani

Arduino: NOT-Gate Circuit

March 24, 2022 Leave a comment

Learning : Electronic NOT-Gate Circuit
Subject: To Build a NOT-Gate Circuit using BC547 Transistor

[NOTE:
W
e are working on Electronic Devices, Voltage, Resistors and other Electronic Parts that may Become HOT due to un-stable current or Wrong Wire Connections..
PLEASE BE CAUTIOUS AND TAKE SAFETY NEEDED PROCEDURES.]

In this Project we will use the BC547 Transistor to build a NOT-Gate circuit, so we will Not use the ADRUINO board.

What we Need

  • 1 2Pin Push-Button.
  • 1 LED
  • 3 Resistors.
  • 1 BC547 Transistor.
  • 1 BreadBoard. [I am using a small 5x7cm]
  • Some Jumper Wires.

Connections

  • Connect the BC547 BasePin to a Resistor Pin1, Then the Pin2 of the Transistor to the Push-Button Pin1.
  • Connect the Push-Button Pin2 to Another Transistor Pin1, Then the Pin2 of the Transistor to BC547 CollectorPin, AND to the Battery(+).
  • Connect the third Transistor Pin1 to BC547 CollectorPin, and the Pin2 of the transistor to LED(+) Pin.
  • Connect the BC547 EmitterPin to the LED(-) Pin by Jumper-wire.
  • Connect the LED(-) Pin to the Battery(-).
Here is the Circuit on the Breadboard
arduino circuit NOT-Gate ali radwani



Run-Time
Since this is a NOT-Gare Circuit then once we connect the Power we can see the LED turns ON, Now if we Press the button and keep pressing, the circuit will be in connecting phase and the LED will tune Off.

Here is a GIF clip of Running Time.



:: ARDUINO PROJECTS LIST ::
[ Click Here to See all ARDUINO Projects ]



ali radwani ahradwani.com python projects codeFollow me on Twitter..

By: Ali Radwani

Daily Sketch: A Dear Face

March 20, 2022 Leave a comment

This is one of my colored sketch back to June 2021 at lockdown time. For Colored sketchbook I am not in Daily based sketch, but trying to keep challenging my self.

May other sketches here ..

LED Fade-Off from Prototype to Gadget

March 10, 2022 Leave a comment

Learning about : Circutes, Capasitor, Push-Button
Subject: LED Fade-off apply it on a PCB Board.

[NOTE:
W
e are working on Electronic Devices, Voltage, Resistors and other Electronic Parts that may Become HOT due to un-stable current or Wrong Wire Connections..
PLEASE BE CAUTIOUS AND TAKE SAFETY NEEDED PROCEDURES.]

In one of my previous Post [Read Here] I did some connection on a breadboard using BC547 and a Capacitor to make an LED Fade-off in 60sec after pushing a button. In this post we will convert that circuit a simpler circuit doing the same thing from a breadboard to a PCB to be as a Gadget.

What we Need: Here is a list of what we will use:

  • 1 LED (I will use a yellow one)
  • 1 PCB Board 5x7cm.
  • 1 1000uF 6.3v Capacitor.
  • 1 Resistor 300 ohm.
  • 1 2pin Push Button.
  • 1 CR2032 Lithium Cell 3V Battery.

Connection: All the connections will be on a 5x7cm PCB Board, I use a thin steel wire to create a strap to hold the Battery, and:

  • Connect the Negative (-) Battery to Pin1 of the Push Button.
  • Pin2 of the Push Button will be connected to the Negative (-) pin of the Capacitor.
  • Connect the 300ohm Resistor Between (+) Pin of the Capacitor and the (+) Pin of the LED.
  • The Negative(-) Pin of the LED will be connected to the Pin2 of the Push Button.


Here is all connections on a small breadboard.

arduino ali radwani ahradwani.com doha qatar circuits



Here I copy the circuit on a small 5x7cm PCB.

arduino ali radwani ahradwani.com doha qatar circuits



Back side Connections.

arduino ali radwani ahradwani.com doha qatar circuits


Finslly, I cut the PCB to a smaller size and Label it.

Now once we Push the Button the LED Turns On and Start Fading-Out. [you may need to give 5-10sec to charge the Capacitor before seeing the Fading Effect]

:: ARDUINO PROJECTS LIST ::
[ Click Here to See all ARDUINO Projects ]

To Download the ARDUINO Project [Code and Diagram] files {No Code in this Project}



ali radwani ahradwani.com python projects codeFollow me on Twitter..

By: Ali Radwani

Daily Sketch challenge..

November 18, 2021 Leave a comment

This sketch back to last week, but I am trying to keep myself in the challenge of “A Sketch A Day ” as far as I can. Here is a sketch and I color it using Autodesk sketchbook Application.

Vestibule: Nikon S9900 Shot 13

October 13, 2021 Leave a comment


Subject: Nikon S9900 in Souq-Waqif Journey

In 2016 I bought Nikon Coolpix S9900, I have Nikon D90, and Nikon 7100 both are DX (crop sensor), but S9900 is my first Coolpix (point & shoot) camera from Nikon, I use to have Sony T100. [:. Read more about my cameras and lenses Here .:]

This Shot: In one of most beautifully ‘Old Bazaar’ in Qatar called “Souq-Waqif” you may find lot’s of Vestibules, here is one that will take you to a Mosque, I take the shot using Nikon S9900.

…Click Image to Enlarge…
photo photography ali radwani doha qatar Souq-Waqif old bazaar Nikon Coolpix S9900
Camera in Hand, F:3.7, ISO:125, Shutter:1/400s, Focal-Point:5mm



::.. To see all my Nikon S9900 Photos Click-Here
::.. To see all my Nikon D7100 Photos Click-Here
::.. To see all my Nikon D90 Photos Click-Here




ali radwani ahradwani.com python projects codeFollow me on Twitter..

By: Ali Radwani

Python: Generate your Data-Set

August 8, 2021 1 comment

Learning : Python, pandas, function
Subject: Generate your CSV dataset using python

[NOTE: To keep the code as simple as we can, We WILL NOT ADD any user input Varevecations. Assuming that our user will Enter the right inputs.]

The Story:
last week i was reading about Data Cleaning, Deep Learning and Machine Learning, and for all we need some data to play with and testing our code. There are several sites providing a free (to certain limits) Data-set. But while i was working, it just come to my mind Why not to write a code to generate some Fake data-set.

Before I start:
The main question was “What is the subject of the data” or Data about What? This is the main question that will guide us to write our code, and tha answer was very..very fast 🙂 .. at that moment I was holding my Coffee Mug, and just jump to my mind, Data about Coffee … Coffee Consumption. So we are taking the data of Coffee Consumption from a Coffee-Shop, the coffee-shop is collecting the following data: Date-Time (of the order), Coffee-Name, Coffee-Type, Coffee-size, Sex, Rank. Here is in more details..

Dat-Time: Date and Time of Order, Date format: dd-mm-yyyy, the Time format: hh:mm (24h)

Coffee-Name: Such as: [black, latte, espresso, americano, cappuccino, mocha, lungo, flat white, irish, macchiato,ristretto, iced coffee]

Coffee-Type: 3n1 , pods, grounded

Coffee Size: samll, medium, large, venti  

Sex: The person how order it male, female 

Rank: if the customer drink the coffee in the shop, will ask for a ranks (1,10) 1:bad, 10:Grate

Scope of Work: We will write several functions to generate random data for each attribute we have, saving the data into a list, then combining all the lists in a pandas dataframe df and save the data_set df to a csv file. Later on we can re-call the file using pandas command df.read_csv(file_name) and manipulate the data.

.::.. Coding ..::.
Let’s start with Date-Time Function: def fake_date_time(from_y,to_y): In this function we will use a random.randint() to generate numbers for day’s, months and years, also for hours and minites. The function will take two arguments from_y, to_y and will return a string like this: dd-mm-yyyy hh:mm … here is the code ..

ali radwani python code project


Now,Coffee Name: def fake_coffee_name() : for Coffee Name I create a list of Coffee Names (from the net) and use random.choice(coffee_name_list) to select one from the list. this function is a one-line code .. here it is ..

 # fake_coffee_name() function

def fake_coffee_name() : 
    """
        Function to randomly select one from the list. 
        
        Return coffee_name 
        
     """ 
    
    coffee_name_list = ['black', 'latte', 'espresso', 'americano', 'cappuccino', 
                         'mocha', 'lungo', 'flat white', 'irish', 'macchiato', 'ristretto', 
                         'iced coffee'
                         ] 
    return random.choice(coffee_name_list) 



Here are another two Functions def fake_coffee_type(): and def fake_coffee_size(): Both are using the random.choice to select from a list.. here is the code ..

]ali radwani python code project



More over, in out dataset we need another two variables sex and rank, both are simple and we don’t need to put them in separate function, we will call the random.choice(‘f’,’m’) to select between Male and Female, and random.randint (1,11) to select a Rank between (1 and 10). Here is the main part of the application, we will use a for loop and append all the returns from the function’s in a list (a list for each attribute) after that we will combine all the list in a dataset using pandas command. Here is the code..

 # Main body of the application

# empty lists of the columns
d_d =[] 
cn_d =[] 
ct_d =[] 
cs_d =[] 
s_d =[] 
r_d = [] 

number_of_rows = 1000 

for x in range(1,number_of_rows): 
    d_d.append(fake_date_time(2000,2022)) 
    cn_d.append(fake_coffee_name()) 
    ct_d.append(fake_coffee_type()) 
    cs_d.append(fake_coffee_size()) 
    s_d.append(random.choice(['f','m'])) 
    r_d.append(random.randint (1,11)) 
    

the_data ={'date_time':d_d, 'c_name':cn_d, 'c_type':ct_d, 'c_size':cs_d, 'sex':s_d, 'rank':r_d } 

df = pd.DataFrame (the_data) 

# to create a CSV file and save the data in it. 
file_name = 'coffee_consumption_v1.csv'
df.to_csv(file_name, index=False)

print(f'\n\n    The data been generated, a file named: {file_name} saved')



Now we have a file called: coffee_consumption_v1.csv saved in the same directory of the .py code file. Here is a sample of the data.

ali radwani python code dataset



We will stop here, and we will do another post to apply pandas commands over the dataset.

..:: Have Fun with Coding ::.. 🙂


To Download my Python code (.py) files Click-Here
Also the Date-Set coffee_consumption_v1 file (.csv) files is available in the same page.



ali radwani ahradwani.com python projects codeFollow me on Twitter..

By: Ali Radwani

Nikon S9900 shots – 5

July 25, 2021 1 comment


Subject: Nikon S9900 Milk and Coffee

In 2016 I bought Nikon Coolpix S9900, I have Nikon D90, and Nikon 7100 both are DX (crop sensor), but S9900 is my first Coolpix (point & shoot) camera from Nikon, I use to have Sony T100. [:. Read more about my cameras and lenses Here .:]

This Shot: I place my Milk Mug in the sun-light coming from a window, the camera on graound level and i took the shot using BW-color from the camera.

…Click Image to Enlarge…
Nikon s9900 coolpix camera Ali radwani ahradwani.com photo Photography

Camera in Hand, F:4 , ISO:160 , Shutter: 1/30s



::.. To see all my Nikon S9900 Photos Click-Here
::.. To see all my Nikon D7100 Photos Click-Here
::.. To see all my Nikon D90 Photos Click-Here




ali radwani ahradwani.com python projects codeFollow me on Twitter..

By: Ali Radwani

Python Sorting Algorithm – Heap Sorting -P5


Learning : Python, Math, Algorithm
Subject: Sorting Algorithm, Heap Sort P5

[NOTE: To keep the code as simple as we can, We WILL NOT ADD any user input Varevecations. Assuming that our user will Enter the right inputs.]


In Last Parts (2, 3 and 4) we wort the Following Functions:

  • Sections Header.
  • Main Menu Function.
  • Entering/Creating the Array.
  • Print-Out or to Display the Array.
  • Check If Array in Max-Heap.
  • Convert Array to Max-Heap.
  • Add Node to Max-Heap.
  • Delete a Node from a Max-Heap.

In this last part-5 we will write the last main Function to aplay the Heap Sorting Algorithm.

Scope of Work: Deleting a Node from a Max-Heap Array is the main function in sorting an Array using Max-Heap Algorithm, the Deleting is always from the Root Node, So if we delete the most top Node [Root] (and store it in index[0] in a temp_array) then we move the Last Node to it’s position and by doing that we miss the Max-Heap state of the Array, so we convert the array to a Max-heap, then we Delete the Root again until we delete all the elements in the Array.. Here the Algorithm:

Assuming we have a Max-Heap Array:
1. Delete the Root Element, and Store it in index[0] in Temp_array.
2. Move the Last Element in the Array to index[0].
3. If the Array not in Max-Heap then Convert it to a Max-Heap.
4. Repeat Steps 1 to 3 Until length of Array is 0.

In our list of Functions up, we have the three Functions we Need to complete/apply a Max-Heap Sorting:
We Delete a Node using def delete_node(arr,inside):
then in a while loop we call both
def check_if_max_heap (arr,inside): and
def convert_to_max_heap (arr,inside): so let’s see the code..

ali radwani ahradwani.com python project code heap sorting algorithm


We finish Max-Heap Sorting Algorithm, ..

..:: Have Fun with Coding ::.. 🙂

To Download my Python code (.py) files Click-Here



ali radwani ahradwani.com python projects codeFollow me on Twitter..

By: Ali Radwani

Python: Kadane’s Algorithm


Learning : Python, Algorithm, Math
Subject: Implement the Kadane’s Algorithm

Definition: Kadane’s Algorithm is to search in a one Dimensional Array [integer positive and negative numbers] for a we will largest Sum of contiguous subarray.

[NOTE: To keep the code as simple as we can, We WILL NOT ADD any user input Varevecations. Assuming that our user will Enter the right inputs.]

Algorithm To find the largest subset sum, we apply coming step:
We will use two variables:
current_max: to hold the max sum of thesub-set
start_again: will be as a flag to re-set the current_max

Algorithm:
1. Start from Element in the array index = 1, save it as start_again. Set Current_max to Array Element in index = 0.

2. Do sumation of start_again with the next element index + 1.

3. If current_max < start_again then re-set current_manx = start_again

4. If start_again < 0 then re-set start_again = 0

5. Repeat from 2 to 4 until the end of the array.

6. If we reach end of the Array, then return the current_max

More from Kadane’s Algorithm:
The aim of Kadane’s Algorithm is to return the Maximum sum of sub-set. But in our code here we will return the following:
1. Maximum sum of largest subset
2. The start Index and the End Index of the subset.
3. printing out the subset.

We will have three options in our application, as following:
1. Kadane’s Algorithm – Fast Run.
2. Kadane’s Algorithm – Step By Step.
9. Exit.

As we are doing in our Algorithms coding, we will use a Main-Menu, and a Function to help the user to enter the Array.

Coding
We will start with def create_array(): and will return the Array that the user will enter. here is the code..

Ali radwani python project code Kadane Algorithm



Now, here is the code for the Main-Menu and the Main application body. In Main application body code, we will use the while True : loop and calling the main_menu() function then with if statement we will check on the user_selection

The Main-Menu
Ali radwani python project code Kadane Algorithm
Here is the Main Application body code..

Ali radwani python project code Kadane Algorithm



Last, we will write the Function to get the Kadane’s Sum in a Fast-Run, the details one will be a copy with mode print-out statement to show the steps .. [All code is in Download Page.]
As we mentioned, Our Kadane’s function will return three things, the Grates Sum of a sub-set, and to position of that sub-set as start index and end index. Here is the code ..

Ali radwani python project code Kadane Algorithm
Here is a Run-Time screen ..

Ali radwani python project code Kadane Algorithm



We done with another Algorithm, looking forwards to solve new one in coming days.

..:: Have Fun with Coding ::.. 🙂


To Download my Python code (.py) files Click-Here



ali radwani ahradwani.com python projects codeFollow me on Twitter..

By: Ali Radwani